Top Description Fields Constructors Methods
org.apache.commons.math3.special

public Class Erf

extends Object
Class Inheritance
Imports
org.apache.commons.math3.util.FastMath

This is a utility class that provides computation methods related to the error functions.

Field Summary

Modifier and TypeField and Description
private static final double
X_CRIT

The number X_CRIT is used by erf(double, double) internally.

Constructor Summary

AccessConstructor and Description
private
Erf()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public static double

Returns:

the error function erf(x)
erf
(double
the value.
x
)

Returns the error function.

public static double

Returns:

erf(x2) - erf(x1)
erf
(double
the first value
x1
,
double
the second value
x2
)

Returns the difference between erf(x1) and erf(x2).

public static double

Returns:

the complementary error function erfc(x)
erfc
(double
the value
x
)

Returns the complementary error function.

public static double

Returns:

t such that x = erfc(t)
erfcInv
(final double
the value
x
)

Returns the inverse erfc.

public static double

Returns:

t such that x = erf(t)
erfInv
(final double
the value
x
)

Returns the inverse erf.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

X_CRITback to summary
private static final double X_CRIT

The number X_CRIT is used by erf(double, double) internally. This number solves erf(x)=0.5 within 1ulp. More precisely, the current implementations of erf(double) and erfc(double) satisfy:
erf(X_CRIT) < 0.5,
erf(Math.nextUp(X_CRIT) > 0.5,
erfc(X_CRIT) = 0.5, and
erfc(Math.nextUp(X_CRIT) < 0.5

Constructor Detail

Erfback to summary
private Erf()

Default constructor. Prohibit instantiation.

Method Detail

erfback to summary
public static double erf(double x)

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, then erf(x) is indistinguishable from either 1 or -1 as a double, so the appropriate extreme value is returned.

Parameters
x:double

the value.

Returns:double

the error function erf(x)

Exceptions
MaxCountExceededException:
if the algorithm fails to converge.
See Also
Gamma#regularizedGammaP(double, double, double, int)
erfback to summary
public static double erf(double x1, double x2)

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:double

the first value

x2:double

the second value

Returns:double

erf(x2) - erf(x1)

erfcback to summary
public static double erfc(double x)

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, then erf(x) is indistinguishable from either 0 or 2 as a double, so the appropriate extreme value is returned.

Parameters
x:double

the value

Returns:double

the complementary error function erfc(x)

Exceptions
MaxCountExceededException:
if the algorithm fails to converge.
Since
2.2
See Also
Gamma#regularizedGammaQ(double, double, double, int)
erfcInvback to summary
public static double erfcInv(final double x)

Returns the inverse erfc.

Parameters
x:double

the value

Returns:double

t such that x = erfc(t)

Since
3.2
erfInvback to summary
public static double erfInv(final double x)

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:double

the value

Returns:double

t such that x = erf(t)

Since
3.2