-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
API extensionAdds new functions or objects to the API.Adds new functions or objects to the API.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.
Description
This RFC proposes adding a new API for computing the error function to the Array API specification in a special functions extension.
Overview
Based on array library comparison data, the API is available in a majority of array libraries in the PyData ecosystem. The error function is particularly important in statistics (e.g., CDF of a normal distribution).
erf
was previously discussed as a candidate for inclusion within the context of a special functions extension. That RFC addressed several topics and design discussions. This RFC seeks to cut through the noise and propose a single API candidate for inclusion in the standard.
Prior Art
- NumPy: not implemented (ref: Adding the
erf
special function to numpy? numpy/numpy#12515). - SciPy: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.erf.html#scipy.special.erf
- CuPy: https://docs.cupy.dev/en/stable/reference/generated/cupyx.scipy.special.erf.html
- Dask: not implemented.
- JAX: https://docs.jax.dev/en/latest/_autosummary/jax.scipy.special.erf.html
- Torch: https://docs.pytorch.org/docs/stable/special.html#torch.special.erf
- TensorFlow: https://www.tensorflow.org/api_docs/python/tf/math/erf
- ndonnx: not implemented.
- MLX: https://ml-explore.github.io/mlx/build/html/python/_autosummary/mlx.core.erf.html#mlx.core.erf
- C99: https://en.cppreference.com/w/c/numeric/math/erf.html
Proposal
def erf(x: array, /) -> array
within a special
functions extension in a manner similar to linalg
and fft
.
Comments
- SciPy supports complex dtypes. JAX does not. As a first pass, I suggest standardizing support for real-valued floating-point arrays. In a follow-up revision, we can add support for complex dtypes.
- Given
erf
's presence in C99, special cases should follow suit as we have done for other special functions in the main namespace.
Metadata
Metadata
Assignees
Labels
API extensionAdds new functions or objects to the API.Adds new functions or objects to the API.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.
Type
Projects
Status
Stage 0