Class Erf

java.lang.Object
com.irurueta.statistics.Erf

public class Erf extends Object
Defines the error function and methods related to it. The error function (or Gaussian function) is a special function typically used in statistics and probability or to solve partial differential equations. The error function is defined as the integral between a given interval of an exponential with a negative squared exponent (like gaussian functions). Such integral can be used for purposes like obtaining the probability of gaussian distributions, because such probability is the integral of a pdf having a similar expression as the error function. The error function (a.k.a. erf) has the following properties: - is an odd function erf(-x) = -erf(x) - erf(0) = 0 - erf(infinity) = 1

Typically, also the complementary error function (a.k.a. erfc) is also used, and it is defined as erfc(x) = 1 - erf(x) The complementary error function has the following properties: - erfc(0) = 1 - erfc(infinity) = 0 - erfc(-x) = 2 - erfc(x).

Both functions (erf and erfc) are special cases of the incomplete gamma function.

This class is based in code of Numerical Recipes 3rd ed. section 6.2.2.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final double[]
    Coefficients of Chebychev polynomial to approximate the error function.
    private static final int
    Number of coefficients to approximate the error function using a Chebychev approximation.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Erf()
    Empty constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    erf(double x)
    Evaluates the error function at x.
    static double
    erfc(double x)
    Evaluates the complementary error function at x.
    private static double
    erfccheb(double z)
    Computes the complementary error function by using the Chebychev method approximation.
    static double
    inverf(double p)
    Evaluates the inverse of the error function at p.
    static double
    inverfc(double p)
    Evaluates the inverse of the complementary error function at p.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • N_COF

      private static final int N_COF
      Number of coefficients to approximate the error function using a Chebychev approximation.
      See Also:
    • COF

      private static final double[] COF
      Coefficients of Chebychev polynomial to approximate the error function.
  • Constructor Details

    • Erf

      private Erf()
      Empty constructor.
  • Method Details

    • erf

      public static double erf(double x)
      Evaluates the error function at x.
      Parameters:
      x - value to evaluate the error function at.
      Returns:
      value of the error function.
    • erfc

      public static double erfc(double x)
      Evaluates the complementary error function at x.
      Parameters:
      x - value to evaluate the complementary error function at.
      Returns:
      value of the complementary error function.
    • inverfc

      public static double inverfc(double p)
      Evaluates the inverse of the complementary error function at p. Then: p = erfc(x) <--> x = inverfc(p)
      Parameters:
      p - value to evaluate the inverse erfc function at.
      Returns:
      result of the evaluation.
    • inverf

      public static double inverf(double p)
      Evaluates the inverse of the error function at p. Then: p = erf(x) <--> x = inverf(p)
      Parameters:
      p - value to evaluate the inverse erf function at.
      Returns:
      result of the evaluation.
    • erfccheb

      private static double erfccheb(double z)
      Computes the complementary error function by using the Chebychev method approximation.
      Parameters:
      z - value to evaluate the function at.
      Returns:
      evaluation of the erfc at provided value.
      Throws:
      IllegalArgumentException - if provided value is negative.