Class Erf
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleerf(double x) Returns the error function.static doubleerf(double x1, double x2) Returns the difference between erf(x1) and erf(x2).static doubleerfc(double x) Returns the complementary error function.static doubleerfcInv(double x) Returns the inverse erfc.static doubleerfInv(double x) Returns the inverse erf.
-
Method Details
-
erf
Returns the error function.erf(x) = 2/√π 0∫x e-t2dt
This implementation computes erf(x) using the
regularized gamma function, following Erf, equation (3)The value returned is always between -1 and 1 (inclusive). If
abs(x) > 40, thenerf(x)is indistinguishable from either 1 or -1 as a double, so the appropriate extreme value is returned.- Parameters:
x- the value.- Returns:
- the error function erf(x)
- Throws:
MaxCountExceededException- if the algorithm fails to converge.- See Also:
-
erfc
Returns the complementary error function.erfc(x) = 2/√π x∫∞ e-t2dt
= 1 -erf(x)This implementation computes erfc(x) using the
regularized gamma function, following Erf, equation (3).The value returned is always between 0 and 2 (inclusive). If
abs(x) > 40, thenerf(x)is indistinguishable from either 0 or 2 as a double, so the appropriate extreme value is returned.- Parameters:
x- the value- Returns:
- the complementary error function erfc(x)
- Throws:
MaxCountExceededException- if the algorithm fails to converge.- Since:
- 2.2
- See Also:
-
erf
Returns the difference between erf(x1) and erf(x2). The implementation uses either erf(double) or erfc(double) depending on which provides the most precise result.- Parameters:
x1- the first valuex2- the second value- Returns:
- erf(x2) - erf(x1)
-
erfInv
Returns the inverse erf.This implementation is described in the paper: Approximating the erfinv function by Mike Giles, Oxford-Man Institute of Quantitative Finance, which was published in GPU Computing Gems, volume 2, 2010. The source code is available here.
- Parameters:
x- the value- Returns:
- t such that x = erf(t)
- Since:
- 3.2
-
erfcInv
Returns the inverse erfc.- Parameters:
x- the value- Returns:
- t such that x = erfc(t)
- Since:
- 3.2
-