-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Open
Labels
function requestA request for a new function or the addition of new arguments/modes to an existing function.A request for a new function or the addition of new arguments/modes to an existing function.module: numerical-stabilityProblems related to numerical stability of operationsProblems related to numerical stability of operationsmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorsmodule: specialFunctions with no exact solutions, analogous to those in scipy.specialFunctions with no exact solutions, analogous to those in scipy.specialtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🚀 Feature
Implement the erfcx(x)
special function, which computes exp(x^2) * erfc(x)
in a numerically stable way. Also for convenience, add logerfc(x) = log(erfc(x))
and logerfcx(x) = log(erfcx(x))
.
erfcx
is available in many numerical packages, such as Matlab, Julia, SciPy R, and others.
From erfcx
it is easy to obtain logerfc
and logerfcx
, but this involves a conditional which can be slow in pure Python code. So I recommend adding logerfc
and logerfcx
as well, which can be implemented as:
def logerfc(x):
if x > 0.0:
return log(erfcx(x)) - x**2
else:
return log(erfc(x))
def logerfcx(x):
if x < 0.0:
return log(erfc(x)) + x^2
else:
return log(erfcx(x))
Motivation
These special functions are very useful whenever we have to work with truncated normal distributions.
manik-hossain, cossio, vadimkantorov, fritzo and ed1d1a8d
Metadata
Metadata
Assignees
Labels
function requestA request for a new function or the addition of new arguments/modes to an existing function.A request for a new function or the addition of new arguments/modes to an existing function.module: numerical-stabilityProblems related to numerical stability of operationsProblems related to numerical stability of operationsmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorsmodule: specialFunctions with no exact solutions, analogous to those in scipy.specialFunctions with no exact solutions, analogous to those in scipy.specialtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module