ParaMonte Fortran 2.0.0 Parallel Monte Carlo and Machine Learning LibrarySee the latest version documentation.
pm_mathErf Module Reference

This module contains classes and procedures for computing the mathematical Inverse Error Function. More...

## Data Types

interface  getErfInv
Generate and return the Inverse Error Function $$\ms{erf}^{-1}(x)$$ for an input real value in range $$(-1, +1)$$ as defined in the details section of pm_mathErf. More...

interface  setErfInv
Return the Inverse Error Function $$\ms{erf}^{-1}(x)$$ for an input real value in range $$(-1, +1)$$ as defined in the details section of pm_mathErf. More...

## Variables

character(*, SK), parameter MODULE_NAME = "@pm_mathErf"

## Detailed Description

This module contains classes and procedures for computing the mathematical Inverse Error Function.

The error function (or the Gauss error function), denoted by $$\ms{erf}(\cdot)$$, is a complex function of a complex variable defined as,

$$\ms{erf}(x) = {\frac{2}{\sqrt{\pi}}} \int_{0}^{x} e^{-t^{2}} ~ \mathrm{d}t ~.$$

This integral is a special (non-elementary) Sigmoid function that occurs in probability, statistics, and partial differential equations.
In many of these applications, the function argument is however a real number.
If the function argument is real, then the function value is also real.
For non-negative values of $$x$$, the error function has the following interpretation: For a random variable $$Y$$ that is normally distributed with mean $$0$$ and standard deviation $$\frac{1}{\sqrt{2}}$$, $$\ms{erf}(x)$$ is the probability that $$Y$$ falls in the range $$[−x, x]$$.
Two closely related functions are the complementary error function (erfc) defined as,

$$\ms{erfc}(x) = 1 - \ms{erf}(x) ~,$$

and the imaginary error function (erfi) defined as,

$$\ms{erfi}(x) = -i\ms{erf}(ix) ~,$$

where $$i$$ is the imaginary unit.

Inverse error function
Given a complex number $$x$$, there is not a unique complex number $$w$$ satisfying $$\ms{erf}(w) = x$$.
Therefore, a true inverse function would be multivalued.
However, for $$−1 < x < 1$$, there is a unique real number denoted $$\ms{erf}^{−1}(x)$$ satisfying,

$$\ms{erf}\left(\ms{erf}^{-1}(x)\right) = x ~.$$

The inverse error function is usually defined with domain $$(−1, 1)$$ and it is restricted to this domain in many computer algebra systems.
However, it can be extended to the disk $$|x| < 1$$ of the complex plane, using the Maclaurin series,

$$\ms{erf}^{-1}(x) = \sum_{k=0}^{\infty} \frac{c_{k}}{2k+1} \left({\frac{\sqrt{\pi}}{2}} x \right)^{2k+1} ~,$$

where $$c_0 = 1$$ and,

\begin{aligned} c_k & = \sum_{m=0}^{k-1} \frac{c_{m} c_{k-1-m}}{(m+1) (2m+1)} \\ & = \left\{1, 1, \frac{7}{6}, \frac{127}{90}, \frac{4369}{2520}, \frac{34807}{16200}, \ldots \right\} ~. \end{aligned}

Therefore,

$$\ms{erf}^{-1}(x) = \frac{\sqrt{\pi}}{2} \left(x + \frac{\pi}{12} x^{3} + \frac{7\pi^{2}}{480} x^{5} + \frac{127\pi^{3}}{40320} x^{7} + \frac{4369\pi^{4}}{5806080} x^{9} + \frac{34807\pi^{5}}{182476800} x^{11} + \cdots \right) ~.$$

The error function value at $$x = \pm\infty$$ is equal to $$\pm1$$.
For $$|x| < 1$$, $$\ms{erf}\left(\ms{erf}^{−1}(x)\right) = x$$.
The inverse complementary error function is defined as,

$$\ms{erfc}^{-1}(1 - x) = \ms{erf}^{-1}(x) ~.$$

For real $$x$$, there is a unique real number $$\ms{erfi}^{−1}(x)$$ satisfying $$\ms{erfi}(\ms{erfi}^{−1}(x) = x$$.
The inverse imaginary error function is defined as $$\ms{erfi}^{−1}(x)$$.

Numerical computation

The erf() and erfc() intrinsic Fortran functions readily return the value of the Error function at any given input value with arbitrary real type and kind.
Theoretically, for any real $$x$$, the Newton root-finding method can be used to compute the inverse error function $$\ms{erfi}^{−1}(x)$$ and for −1 ≤ x ≤ 1, the following Maclaurin series converges:

$$\ms{erfi}^{-1}(x) = \sum_{k=0}^{\infty}{\frac{(-1)^{k}c_{k}}{2k+1}}\left({\frac{\sqrt{\pi}}{2}}(x)\right)^{2k+1} ~,$$

where $$c_k$$ is defined as above.

The procedures of this module combine multiple varying-precision approaches to make a decision at compile-time about the best strategy for computing the inverse error function.

pm_mathBeta
pm_mathGamma
pm_mathErf
pm_distNorm
pm_distNorm
pm_distNorm
pm_distNorm
Test:
test_pm_mathErf

Final Remarks

If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.

1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Nov 10, 2009, 8:53 PM, Michigan

## ◆ MODULE_NAME

 character(*, SK), parameter pm_mathErf::MODULE_NAME = "@pm_mathErf"

Definition at line 111 of file pm_mathErf.F90.