Return the regularized Upper Incomplete Gamma function for the specified lower limit x
and shape parameter, evaluated by the Legendre continued fraction representation of the Incomplete Gamma function.
The regularized Upper Incomplete Gamma function is defined as,
\begin{equation}
\large
Q(\kappa, x) = \frac{1}{\Gamma(\kappa)} \int_x^{+\infty}~t^{\kappa1}{\mathrm e}^{t} ~ dt ~,
\end{equation}
where \((\kappa > 0, x > 0)\) are respectively the shape parameter of the Gamma function (or distribution) and the lower limit in the integral of the Upper Incomplete Gamma function.
By definition, the Upper Incomplete Gamma function is always positive.
 Parameters

[out]  gammaIncUpp  : The input scalar of the same type and kind as the input x , representing the regularized Upper Incomplete Gamma function. 
[in]  x  : The input scalar of type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128), representing the lower limit in the integral of the Upper Incomplete Gamma function. 
[in]  logGammaKappa  : The input scalar the same type and kind as the input x , representing the precomputed \(\log(\Gamma(\kappa))\) which can be computed by calling the Fortran intrinsic function log_gamma(kappa) .

[in]  kappa  : The input scalar of the same type and kind as the input x , representing the shape parameter ( \(\kappa\)) of the Upper Incomplete Gamma function. 
[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 (positive) number of iterations taken for the Legendre continued fraction representation to converge or its negative if the Legendre continued fraction representation fails to converge.
A convergence failure is likely to happen if the input value for kappa is too large.
A negative value implies the lack of convergence.

[in]  tol  : The input scalar of the same type and kind as x , representing the relative accuracy in the convergence checking of the Legendre continued fraction representation of the Gamma function.
(optional, default = 10 * epsilon(x) ). 
Possible calling interfaces ⛓
Return the regularized Upper Incomplete Gamma function for the specified lower limit x and shape para...
This module contains procedures and generic interfaces for the Lower and Upper Incomplete Gamma funct...
 Warning
 The
kappa
and x
input arguments must be positive real
numbers with logGammaKappa = log_gamma(kappa)
where log_gamma()
is a Fortran intrinsic function.
Furthermore, tol << 1.
must hold, if it is present as an input argument.
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
 getGammaIncLow
setGammaIncLow
getGammaIncUpp
setGammaIncUpp
setGammaIncLowSeries
See also The Numerical Recipes by Press et al. 1992 for further details about the Incomplete Gamma function.
Example usage ⛓
12 integer(IK) ,
parameter :: NP
= 1000_IK
13 real(RKH) :: gamIncUpp_RKH, x_RKH, kappa_RKH
14 real(RKD) :: gamIncUpp_RKD, x_RKD, kappa_RKD
15 real(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 Upper Incomplete Gamma Function using its Continued Fraction representation.")
33 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
34 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
42 call disp%show(
"call setGammaIncUppContFrac(gamIncUpp_RKS, x_RKS, logGammaKappa = log_gamma(kappa_RKS), kappa = kappa_RKS, info = info)")
43 call setGammaIncUppContFrac(gamIncUpp_RKS, x_RKS, logGammaKappa
= log_gamma(kappa_RKS), kappa
= kappa_RKS, info
= info)
55 call disp%show(
"call setGammaIncUppContFrac(gamIncUpp_RKD, x_RKD, logGammaKappa = log_gamma(kappa_RKD), kappa = kappa_RKD, info = info)")
56 call setGammaIncUppContFrac(gamIncUpp_RKD, x_RKD, logGammaKappa
= log_gamma(kappa_RKD), kappa
= kappa_RKD, info
= info)
68 call disp%show(
"call setGammaIncUppContFrac(gamIncUpp_RKH, x_RKH, logGammaKappa = log_gamma(kappa_RKH), kappa = kappa_RKH, info = info)")
69 call setGammaIncUppContFrac(gamIncUpp_RKH, x_RKH, logGammaKappa
= log_gamma(kappa_RKH), kappa
= kappa_RKH, info
= info)
83 real(RKS) :: x_RKS(NP)
84 integer :: fileUnit, i
87 open(newunit
= fileUnit, file
= "setGammaIncUppContFrac.RK.txt")
89 call setGammaIncUppContFrac(gamIncUpp_RKS, x_RKS(i), logGammaKappa
= log_gamma(kappa_RKS), kappa
= kappa_RKS, info
= info)
90 write(fileUnit,
"(2(g0,:,' '))") x_RKS(i), gamIncUpp_RKS
Return the linSpace output argument with size(linSpace) elements of evenlyspaced 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 typeparameters 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 CFortran Interoper...
integer, parameter RKD
The double precision real kind in Fortran mode. On most platforms, this is an 64bit real kind.
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in CFortran Intero...
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highestprecision real kind t...
integer, parameter RKS
The singleprecision real kind in Fortran mode. On most platforms, this is an 32bit real kind.
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort fpp standardsemantics 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 /standardsemantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran cpp ffreelinelengthnone O3 Wl,rpath,../../../lib I../../../inc main.F90 ../../../lib/libparamonte* o main.exe
Example output ⛓
13call setGammaIncUppContFrac(gamIncUpp_RKS, x_RKS, logGammaKappa
= log_gamma(kappa_RKS), kappa
= kappa_RKS, info
= info)
24call setGammaIncUppContFrac(gamIncUpp_RKD, x_RKD, logGammaKappa
= log_gamma(kappa_RKD), kappa
= kappa_RKD, info
= info)
32+2.00000000000000000000000000000000000
34+1.50000000000000000000000000000000000
35call setGammaIncUppContFrac(gamIncUpp_RKH, x_RKH, logGammaKappa
= log_gamma(kappa_RKH), kappa
= kappa_RKH, info
= info)
37+0.261464129949110622202822075975924763
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
15xlab = {
"CK" :
r"x ( real/imaginary )"
16 ,
"IK" :
r"x ( integervalued )"
17 ,
"RK" :
r"x ( realvalued )"
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 Upper Incomplete Gamma\nFunction via Continued Fraction", 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 951 of file pm_mathGamma.F90.