Main Content

Error function

`erf(`

returns the Error Function evaluated for each element
of `x`

)`x`

.

You can also find the standard normal probability distribution using the function

`normcdf`

(Statistics and Machine Learning Toolbox). The relationship between the error function`erf`

and`normcdf`

is$$\text{normcdf}\left(x\right)=\frac{1}{2}\left(1-\text{erf}\left(\frac{-x}{\sqrt{2}}\right)\right).$$

For expressions of the form

`1 - erf(x)`

, use the complementary error function`erfc`

instead. This substitution maintains accuracy. When`erf(x)`

is close to`1`

, then`1 - erf(x)`

is a small number and might be rounded down to`0`

. Instead, replace`1 - erf(x)`

with`erfc(x)`

.