Probability and statistics
Evaluate Gaussian-related integrals or distributions involving the error function.
SciPy · Function
Computes the error function for real or complex arguments. It is a universal function that returns values elementwise for array inputs and can optionally use a supplied output array.
Call the universal function with a scalar or array-like input. It evaluates the error function elementwise and can optionally write results into a supplied output array.
scipy.special.erf(z, out=None)| Name | Type | Description |
|---|---|---|
z | ndarray | Input array of real or complex values. |
out | ndarray, optional | Optional output array for the function values. |
res: scalar or ndarray — The values of the error function at the given points z.
import numpy as np
from scipy import special
z = np.array([-1.0, 0.0, 1.0])
print(special.erf(z))Computes the error function elementwise for a NumPy array.
Evaluate Gaussian-related integrals or distributions involving the error function.
Apply the function to vectors or matrices without writing explicit loops.
Use compatible Array API backends when testing SciPy's experimental backend support.
scipy.special.erf computes the error function for real or complex arguments. Mathematically, it is defined as 2 divided by the square root of pi times the integral of exp(-t squared) from zero to z.
Follow-up: How is erf related to the standard normal CDF? The documentation gives Phi(z) = 1/2 [1 + erf(z / sqrt(2))].
The input z is an ndarray, and the result is a scalar or ndarray containing the corresponding error-function values. As a ufunc, it supports elementwise array computation.
Follow-up: How can callers avoid allocating a separate result array? Supply a compatible out array through the optional out parameter.
The function accepts an optional out argument. This lets callers provide an output array in which SciPy stores the function values.
Follow-up: What related special functions should you consider for numerical alternatives? erfc, erfcx, erfi, erfinv, erfcinv, and wofz are listed as related functions.
erfcerfcxerfierfinverfcinvwofz