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...
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.
The complementary inverse error function \(\ms{erfc}^{-1}(y), y\in(0, 2)\) can be readily computed as getErfInv(1 - y)
.
See the documentation of pm_mathErf for more information.
- Parameters
-
[in] | x | : The input scalar (or array of the same shape as other array-like arguments) of the same type and kind as the output erfinv .
|
[in] | abserr | : The input positive scalar (or array of the same shape as other array-like arguments) of the same type and kind as the output erfinv .
If present, the output approximate value for the inverse error function is guaranteed to be at most abserr away from the true value \(\ms{erf}^{-1}(x)\).
This guarantee is currently tested and validated up to \(2\times10^{-26}\).
(optional, default = 100 * epsilon(x) ) |
- Returns
erfinv
: The output scalar (or array of the same shape as input array-like arguments) of,
-
type
real
of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the approximate value of the inverse error function at the specified input point x
.
Possible calling interfaces ⛓
erfinv(..)
= getErfInv(x(..), abserr
= abserr(..))
Generate and return the Inverse Error Function for an input real value in range as defined in the d...
This module contains classes and procedures for computing the mathematical Inverse Error Function.
- Warning
- The condition
0 < abserr
must hold for the corresponding input arguments.
The conditions -1 < x .and. x < 1
must hold for the corresponding input arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
-
The
pure
procedure(s) documented herein become impure
when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1
.
By default, these procedures are pure
in release
build and impure
in debug
and testing
builds.
- See also
- getErfInv
setErfInv
getNormCDF
setNormCDF
getNormQuan
setNormQuan
getNormRand
setNormRand
getNormLogPDF
setNormLogPDF
Example usage ⛓
9 real(RKH),
allocatable :: erfinv(:)
11 type(display_type) :: disp
15 call disp%show(
"erfinv = [real(RKH) :: getErfInv(0.), getErfInv(0.d0)]")
24 call disp%show(
"erfinv = [getErfInv(-1. + epsilon(0.))]")
33 call disp%show(
"erfinv = [getErfInv(+1. - epsilon(0.))]")
42 call disp%show(
"erfinv = getErfInv([real :: -.99, -.75, -0.5, -0.1, 0., .1, .5, .75, .99])")
43 erfinv
= getErfInv([real ::
-.
99,
-.
75,
-0.5,
-0.1,
0., .
1, .
5, .
75, .
99])
57 integer(IK) ,
parameter :: NP
= 2000
58 integer :: fileUnit, i
59 real(RKG) :: erfval(NP)
60 call setLinSpace(erfval,
-1._RKG + epsilon(
0._RKL),
1._RKG - epsilon(
0._RKL))
61 open(newunit
= fileUnit, file
= "getErfInv.RK.txt")
63 write(fileUnit,
"(*(g0,:,' '))")
real(erfval(i),
RKD),
getErfInv(
real(erfval(i),
RKD))
66 open(newunit
= fileUnit, file
= "getErfInv.RKS.abserr.txt")
68 write(fileUnit,
"(*(g0,:,' '))")
real(erfval(i),
RKS),
real(erfval(i),
RKS)
- erf(
real(
getErfInv(
real(erfval(i),
RKS)),
RKB))
71 open(newunit
= fileUnit, file
= "getErfInv.RKD.abserr.txt")
73 write(fileUnit,
"(*(g0,:,' '))")
real(erfval(i),
RKD),
real(erfval(i),
RKD)
- erf(
real(
getErfInv(
real(erfval(i),
RKD)),
RKB))
76 open(newunit
= fileUnit, file
= "getErfInv.RKH.abserr.txt")
78 write(fileUnit,
"(*(g0,:,' '))")
real(erfval(i),
RKH),
real(erfval(i),
RKH)
- erf(
real(
getErfInv(
real(erfval(i),
RKH)),
RKB))
Return the linSpace output argument with size(linSpace) elements of evenly-spaced values over the int...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains procedures and generic interfaces for generating arrays with linear or logarithm...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter RKB
The scalar integer constant of intrinsic default kind, representing the Best-precision real kind supp...
integer, parameter RKL
The scalar integer constant of intrinsic default kind, representing the lowest-precision real kind ty...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter RKD
The double precision real kind in Fortran mode. On most platforms, this is an 64-bit real kind.
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
4+0.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000
6+0.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000
11-3.74392127990722656250000000000000000
13-0.999999880790818503613783522210309248
18+3.74392127990722656250000000000000000
20+0.999999880790818503613783522210309344
23erfinv
= getErfInv([real ::
-.
99,
-.
75,
-0.5,
-0.1,
0., .
1, .
5, .
75, .
99])
25-1.82138657569885253906250000000000000,
-0.813419818878173828125000000000000000,
-0.476936280727386474609375000000000000,
-0.888559892773628234863281250000000000E-1,
+0.00000000000000000000000000000000000,
+0.888559892773628234863281250000000000E-1,
+0.476936280727386474609375000000000000,
+0.813419818878173828125000000000000000,
+1.82138657569885253906250000000000000
27-0.990000008506047801752279420046811002,
-0.749999983278341053252938360742249376,
-0.500000004065233062995271124000763142,
-0.999999986376798060532971720489789201E-1,
+0.00000000000000000000000000000000000,
+0.999999986376798060532971720489789201E-1,
+0.500000004065233062995271124000763142,
+0.749999983278341053252938360742249376,
+0.990000008506047801752279420046810906
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
12parent = os.path.basename(os.path.dirname(__file__))
13pattern = parent +
"*.txt"
15fileList = glob.glob(pattern)
18 df = pd.read_csv(file, delimiter =
" ")
20 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
23 for i
in range(1,len(df.values[0,:]+1)):
25 plt.plot( df.values[:, 0]
30 plt.xticks(fontsize = fontsize - 2)
31 plt.yticks(fontsize = fontsize - 2)
32 ax.set_xlabel(
"x", fontsize = fontsize)
34 nbit = file.split(
".")[1][2:]
35 label = [
r"x - erf(erfinv(x))"]
36 ax.set_ylabel(
"{}-bits Absolute Error".format(nbit), fontsize = fontsize)
38 label = [
r"erfinv(x)"]
39 ax.set_ylabel(
"Inverse Error Function", fontsize = fontsize)
41 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
42 ax.tick_params(axis =
"y", which =
"minor")
43 ax.tick_params(axis =
"x", which =
"minor")
51 plt.savefig(file.replace(
".txt",
".png"))
Visualization of the example output ⛓
- 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.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- Author:
- Amir Shahmoradi, Nov 10, 2009, 8:53 PM, Michigan
Definition at line 191 of file pm_mathErf.F90.