Class Erf

java.lang.Object
org.hipparchus.special.Erf

public class Erf extends Object
This is a utility class that provides computation methods related to the error functions.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    static double
    erf(double x)
    Returns the error function. erf(x)=2πt=0xet2dt
    static double
    erf(double x1, double x2)
    Returns the difference between erf(x1) and erf(x2).
    static <T extends CalculusFieldElement<T>>
    T
    erf(T x)
    Returns the error function. erf(x)=2πt=0xet2dt
    static <T extends CalculusFieldElement<T>>
    T
    erf(T x1, T x2)
    Returns the difference between erf(x1) and erf(x2).
    static double
    erfc(double x)
    Returns the complementary error function. \[ \mathrm{erfc}(x) = \frac{2}{\sqrt{\pi}} \int_{t=x}^\infty e^{-t^2}dt = 1 - \mathrm{erf}
    static <T extends CalculusFieldElement<T>>
    T
    erfc(T x)
    Returns the complementary error function. erfc(x)=2πxet2dt=1erf(x)
    static double
    erfcInv(double x)
    Returns the inverse erfc.
    static <T extends CalculusFieldElement<T>>
    T
    erfcInv(T x)
    Returns the inverse erfc.
    static double
    erfInv(double x)
    Returns the inverse erf.
    static <T extends CalculusFieldElement<T>>
    T
    erfInv(T x)
    Returns the inverse erf.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details Link icon

    • erf Link icon

      public static double erf(double x)
      Returns the error function. erf(x)=2πt=0xet2dt

      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 - the value.
      Returns:
      the error function erf(x)
      Throws:
      MathIllegalStateException - if the algorithm fails to converge.
      See Also:
    • erf Link icon

      public static <T extends CalculusFieldElement<T>> T erf(T x)
      Returns the error function. erf(x)=2πt=0xet2dt

      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.

      Type Parameters:
      T - type of the field elements
      Parameters:
      x - the value.
      Returns:
      the error function erf(x)
      Throws:
      MathIllegalStateException - if the algorithm fails to converge.
      See Also:
    • erfc Link icon

      public static double erfc(double x)
      Returns the complementary error function. \[ \mathrm{erfc}(x) = \frac{2}{\sqrt{\pi}} \int_{t=x}^\infty e^{-t^2}dt = 1 - \mathrm{erf}

      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 - the value
      Returns:
      the complementary error function erfc(x)
      Throws:
      MathIllegalStateException - if the algorithm fails to converge.
      See Also:
    • erfc Link icon

      public static <T extends CalculusFieldElement<T>> T erfc(T x)
      Returns the complementary error function. erfc(x)=2πxet2dt=1erf(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. This implies that the current implementation does not allow the use of Dfp with extended precision.

      Type Parameters:
      T - type of the field elements
      Parameters:
      x - the value
      Returns:
      the complementary error function erfc(x)
      Throws:
      MathIllegalStateException - if the algorithm fails to converge.
      See Also:
    • erf Link icon

      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 - the first value
      x2 - the second value
      Returns:
      erf(x2) - erf(x1)
    • erf Link icon

      public static <T extends CalculusFieldElement<T>> T erf(T x1, T 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.

      Type Parameters:
      T - type of the field elements
      Parameters:
      x1 - the first value
      x2 - the second value
      Returns:
      erf(x2) - erf(x1)
    • erfInv Link icon

      public static double erfInv(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 - the value
      Returns:
      t such that x = erf(t)
    • erfInv Link icon

      public static <T extends CalculusFieldElement<T>> T erfInv(T 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.

      Type Parameters:
      T - type of the filed elements
      Parameters:
      x - the value
      Returns:
      t such that x = erf(t)
    • erfcInv Link icon

      public static double erfcInv(double x)
      Returns the inverse erfc.
      Parameters:
      x - the value
      Returns:
      t such that x = erfc(t)
    • erfcInv Link icon

      public static <T extends CalculusFieldElement<T>> T erfcInv(T x)
      Returns the inverse erfc.
      Type Parameters:
      T - type of the field elements
      Parameters:
      x - the value
      Returns:
      t such that x = erfc(t)