Return the regularized Lower Incomplete Gamma function for the specified shape parameter ( \(\kappa\)) and upper limit of the integral x
.
The regularized Lower Incomplete Gamma function is defined as,
\begin{equation}
\large
P(\kappa, x) = \frac{1}{\Gamma(\kappa)} \int_0^x~t^{\kappa-1}{\mathrm e}^{-t} ~ dt ~,
\end{equation}
where \((\kappa > 0, x > 0)\) should hold, with \(\kappa\) representing the shape parameter of the Gamma function (or distribution) and \(x\) representing the upper limit in the integral of the Lower Incomplete Gamma function.
Note that this integral is bounded between zero and one ( \([0,1]\)).
The regularized Lower Incomplete Gamma function also represents the Cumulative Distribution Function (CDF) of the univariate Gamma distribution with the specified shape parameter and standardized x
(with the scale parameter of unity).
The regularized Upper Incomplete Gamma function is defined as,
\begin{equation}
\large
Q(\kappa, x) = \frac{1}{\Gamma(\kappa)} \int_x^{+\infty}~t^{\kappa-1}{\mathrm e}^{-t} ~ dt ~,
\end{equation}
where \((\kappa > 0, x > 0)\) should hold, with \(\kappa\) representing the shape parameter of the Gamma function (or distribution) and \(x\) representing the lower limit in the integral of the Upper Incomplete Gamma function.
Note that this integral is bounded between zero and one ( \([0,1]\)).
The regularized Upper Incomplete Gamma function also represents the complement of the Cumulative Distribution Function (CDF) of the univariate Gamma distribution with the specified shape parameter and standardized x
(with the scale parameter of unity).
- Parameters
-
[out] | gammaIncLow | : The output scalar of the same type and kind as the input argument x representing the Lower Incomplete Gamma function for the specified kappa and lower limit.
Note that gammaIncLow is, by definition, always positive in the range \([0, 1]\).
|
[out] | gammaIncUpp | : The output scalar of same type and kind as the input argument x representing the Upper Incomplete Gamma function for the specified kappa and lower limit.
Note that gammaIncUpp is, by definition, always positive.
|
[in] | x | : The input scalar of the type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128), representing the upper limit in the integral of the Lower Incomplete Gamma function \(P(\kappa,x)\). |
[in] | kappa | : The input scalar of the same type and kind as x , representing the shape parameter ( \(\kappa\)) of the Lower Incomplete Gamma function \(P(\kappa,x)\). |
[out] | info | : The input scalar or array of the same shape as other input arguments of type integer of default kind IK.
On output, it is set to zero if the algorithm succeeds to converge or a negative value if the algorithm fails to converge.
A convergence failure could happen if the input value for kappa is too large.
A negative value implies the lack of convergence.
|
Possible calling interfaces ⛓
call setGammaInc(gammaIncLow, gammaIncUpp, x, kappa, info)
Return the regularized Lower Incomplete Gamma function for the specified shape parameter ( ) and uppe...
This module contains procedures and generic interfaces for the Lower and Upper Incomplete Gamma funct...
- Warning
- 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
- setGammaInc
getGammaIncUpp
getGammaIncLow
Example usage ⛓
12 integer(IK) ,
parameter :: NP
= 1000_IK
13 real(RKH) :: gamIncLow_RKH, gamIncUpp_RKH, x_RKH, kappa_RKH
14 real(RKD) :: gamIncLow_RKD, gamIncUpp_RKD, x_RKD, kappa_RKD
15 real(RKS) :: gamIncLow_RKS, gamIncUpp_RKS, x_RKS, kappa_RKS
18 type(display_type) :: disp
30 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
31 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
32 call disp%show(
"! Compute the regularized Lower Incomplete Gamma Function using its series representation.")
33 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
34 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
42 call disp%show(
"call setGammaInc(gamIncLow_RKS, gamIncUpp_RKS, x_RKS, kappa = kappa_RKS, info = info)")
43 call setGammaInc(gamIncLow_RKS, gamIncUpp_RKS, x_RKS, kappa
= kappa_RKS, info
= info)
44 call disp%show(
"[gamIncLow_RKS, gamIncUpp_RKS]")
45 call disp%show( [gamIncLow_RKS, gamIncUpp_RKS] )
55 call disp%show(
"call setGammaInc(gamIncLow_RKD, gamIncUpp_RKD, x_RKD, kappa = kappa_RKD, info = info)")
56 call setGammaInc(gamIncLow_RKD, gamIncUpp_RKD, x_RKD, kappa
= kappa_RKD, info
= info)
57 call disp%show(
"[gamIncLow_RKD, gamIncUpp_RKD]")
58 call disp%show( [gamIncLow_RKD, gamIncUpp_RKD])
68 call disp%show(
"call setGammaInc(gamIncLow_RKH, gamIncUpp_RKH, x_RKH, kappa = kappa_RKH, info = info)")
69 call setGammaInc(gamIncLow_RKH, gamIncUpp_RKH, x_RKH, kappa
= kappa_RKH, info
= info)
70 call disp%show(
"[gamIncLow_RKH, gamIncUpp_RKH]")
71 call disp%show( [gamIncLow_RKH, gamIncUpp_RKH] )
83 real(RKS) :: x_RKS(NP)
84 integer :: fileUnit, i
87 open(newunit
= fileUnit, file
= "setGammaInc.RK.txt")
89 call setGammaInc(gamIncLow_RKS, gamIncUpp_RKS, x_RKS(i), kappa
= kappa_RKS, info
= info)
90 write(fileUnit,
"(2(g0,:,' '))") x_RKS(i), gamIncLow_RKS
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 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 ⛓
13call setGammaInc(gamIncLow_RKS, gamIncUpp_RKS, x_RKS, kappa
= kappa_RKS, info
= info)
14[gamIncLow_RKS, gamIncUpp_RKS]
15+0.738535821,
+0.261464179
24call setGammaInc(gamIncLow_RKD, gamIncUpp_RKD, x_RKD, kappa
= kappa_RKD, info
= info)
25[gamIncLow_RKD, gamIncUpp_RKD]
26+0.73853587005088861,
+0.26146412994911145
32+2.00000000000000000000000000000000000
34+1.50000000000000000000000000000000000
35call setGammaInc(gamIncLow_RKH, gamIncUpp_RKH, x_RKH, kappa
= kappa_RKH, info
= info)
36[gamIncLow_RKH, gamIncUpp_RKH]
37+0.738535870050889377797177924024077018,
+0.261464129949110622202822075975923030
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
15xlab = {
"CK" :
r"x ( real/imaginary )"
16 ,
"IK" :
r"x ( integer-valued )"
17 ,
"RK" :
r"x ( real-valued )"
19labels = [
r"shape parameter: $\kappa = 2$"]
21for kind
in [
"IK",
"CK",
"RK"]:
23 pattern =
"*." + kind +
".txt"
24 fileList = glob.glob(pattern)
25 if len(fileList) == 1:
27 df = pd.read_csv(fileList[0], delimiter =
" ")
29 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
33 plt.plot( df.values[:, 0]
38 plt.plot( df.values[:, 1]
44 plt.plot( df.values[:, 0]
50 plt.xticks(fontsize = fontsize - 2)
51 plt.yticks(fontsize = fontsize - 2)
52 ax.set_xlabel(xlab[kind], fontsize = fontsize)
53 ax.set_ylabel(
"Regularized Lower\nIncomplete Gamma Function", fontsize = fontsize)
55 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
56 ax.tick_params(axis =
"y", which =
"minor")
57 ax.tick_params(axis =
"x", which =
"minor")
65 plt.savefig(fileList[0].replace(
".txt",
".png"))
67 elif len(fileList) > 1:
69 sys.exit(
"Ambiguous file list exists.")
Visualization of the example output ⛓
- Test:
- test_pm_mathGamma
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:
- Fatemeh Bagheri, Monday 12:36 pm, August 16, 2021, Dallas TX
Definition at line 416 of file pm_mathGamma.F90.