erfinv
Inverse error function
Syntax
Description
erfinv(
returns
the Inverse Error Function evaluated
for each element of x
)x
. For inputs outside the
interval [-1 1]
, erfinv
returns NaN
.
Examples
Find Inverse Error Function of Value
erfinv(0.25)
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]; erfinv(M)
ans = 2×2
0 -0.4769
1.1631 -0.1791
Plot the Inverse Error Function
Plot the inverse error function for -1 < x < 1.
x = -1:0.01:1; y = erfinv(x); plot(x,y) grid on xlabel('x') ylabel('erfinv(x)') title('Inverse Error Function for -1 < x < 1')
Generate Gaussian Distributed Random Numbers
Generate Gaussian distributed random numbers using uniformly distributed random numbers. To convert a uniformly distributed random number to a Gaussian distributed random number , 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.
rng('default')
x = -1 + 2*rand(1,10000);
y = sqrt(2)*erfinv(x);
h = histogram(y);
Input Arguments
x
— Input
real number | vector of real numbers | matrix of real numbers | multidimensional array of real numbers
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
Inverse Error Function
The inverse error function erfinv is defined as the inverse of the error function, such that
Tips
For expressions of the form
erfinv(1-x)
, use the complementary inverse error functionerfcinv
instead. This substitution maintains accuracy. Whenx
is close to1
, then1 - x
is a small number and may be rounded down to0
. Instead, replaceerfinv(1-x)
witherfcinv(x)
.
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
The
erfinv
function fully supports tall arrays. For more information,
see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Strict single-precision calculations are not supported. In the generated code, single-precision inputs produce single-precision outputs. However, variables inside the function might be double-precision.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The erfinv
function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray
(Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)