Generate and 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 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
-
[in] | x | : The input scalar of 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)\). |
- Returns
gammaIncLow
: The output scalar of the same type and kind as the output argument x
representing the Lower Incomplete Gamma function for the specified kappa
and upper limit.
Note that gammaIncLow
is, by definition, always positive in the range \([0, 1]\).
Note that the procedure will abruptly end the program by calling error stop
if the computation of the Incomplete Gamma function fails to converge**.
Possible calling interfaces ⛓
Generate and return the regularized Lower Incomplete Gamma function for the specified shape parameter...
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.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
- See also
- setGammaInc
getGammaIncLow
setGammaInc
Example usage ⛓
12 type(display_type) :: disp
16 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
17 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
18 call disp%show(
"! Compute the regularized Lower Incomplete Gamma Function using its series representation.")
19 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
20 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
24 call disp%show(
"getGammaIncLow(x = 1.5_RKS, kappa = 2._RKS)")
29 call disp%show(
"getGammaIncLow(x = 1.5_RKD, kappa = 2._RKD)")
34 call disp%show(
"getGammaIncLow(x = 1.5_RKH, kappa = 2._RKH)")
40 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
41 call disp%show(
"! Compute the regularized Lower Incomplete Gamma Function for a vector of points.")
42 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
47 call disp%show(
"getGammaIncLow(x = [0._RKS, 1._RKS, 10._RKS], kappa = 2._RKS)")
52 call disp%show(
"getGammaIncLow(x = [0._RKD, 1._RKD, 10._RKD], kappa = 2._RKD)")
57 call disp%show(
"getGammaIncLow(x = [0._RKH, 1._RKH, 10._RKH], kappa = 2._RKH)")
63 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
64 call disp%show(
"! Compute the regularized Lower Incomplete Gamma Function for a vector of shape parameters.")
65 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
70 call disp%show(
"getGammaIncLow(x = 1._RKS, kappa = [0.1_RKS, 1._RKS, 10._RKS])")
75 call disp%show(
"getGammaIncLow(x = 1._RKD, kappa = [0.1_RKD, 1._RKD, 10._RKD])")
80 call disp%show(
"getGammaIncLow(x = 1._RKH, kappa = [0.1_RKH, 1._RKH, 10._RKH])")
86 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
87 call disp%show(
"! Compute the regularized Lower Incomplete Gamma Function for a vector of points and shape parameters.")
88 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
94 integer(IK) :: i, rprecision
95 integer(IK),
allocatable :: exprange(:)
98 call disp%show(
"rprecision = precision(0._RKS) / 2")
99 rprecision
= precision(
0._RKS)
/ 2
102 call disp%show(
"exprange = [(i, i = -rprecision, rprecision)]")
103 exprange
= [(i, i
= -rprecision, rprecision)]
106 call disp%show(
"getGammaIncLow(x = 10._RKS**exprange, kappa = 10._RKS**exprange)")
111 call disp%show(
"rprecision = precision(0._RKD) / 2")
112 rprecision
= precision(
0._RKD)
/ 2
115 call disp%show(
"exprange = [(i, i = -rprecision, rprecision)]")
116 exprange
= [(i, i
= -rprecision, rprecision)]
119 call disp%show(
"getGammaIncLow(x = 10._RKD**exprange, kappa = 10._RKD**exprange)")
124 call disp%show(
"rprecision = precision(0._RKH) / 2")
125 rprecision
= precision(
0._RKH)
/ 2
128 call disp%show(
"exprange = [(i, i = -rprecision, rprecision)]")
129 exprange
= [(i, i
= -rprecision, rprecision)]
132 call disp%show(
"getGammaIncLow(x = 10._RKH**exprange, kappa = 10._RKH**exprange)")
145 integer(IK) ,
parameter :: NP
= 1000_IK
146 real(RKS) :: x_RKS(NP)
147 integer :: fileUnit, i
150 open(newunit
= fileUnit, file
= "getGammaIncLow.RK.txt")
152 write(fileUnit,
"(*(g0,:,' '))") x_RKS(i),
getGammaIncLow(x_RKS(i), kappa
= [
1.0_RKS,
2.5_RKS,
5.0_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 ⛓
18+0.442174599628925427666798823089968559
27+0.00000000,
+0.264241129,
+0.999500573
31+0.0000000000000000,
+0.26424111765711528,
+0.99950060077261271
35+0.00000000000000000000000000000000000,
+0.264241117657115356808952459677078110,
+0.999500600772612666633108493328833987
44+0.975872695,
+0.632120550,
+0.111424356E-6
48+0.97587265627367237,
+0.63212055882855767,
+0.11142547833872021E-6
52+0.975872656273672222617030564366645365,
+0.632120558828557678404476229838539127,
+0.111425478338720677353048198587738909E-6
60rprecision
= precision(
0._RKS)
/ 2
63exprange
= [(i, i
= -rprecision, rprecision)]
65-3,
-2,
-1,
+0,
+1,
+2,
+3
67+0.993687630,
+0.960347414,
+0.827551782,
+0.632120550,
+0.542070270,
+0.513298810,
+0.504205227
70rprecision
= precision(
0._RKD)
/ 2
73exprange
= [(i, i
= -rprecision, rprecision)]
75-7,
-6,
-5,
-4,
-3,
-2,
-1,
+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7
77+0.99999844591319076,
+0.99998676179091028,
+0.99989064869904365,
+0.99913704186899344,
+0.99368764670886034,
+0.96034742352150926,
+0.82755175958585059,
+0.63212055882855767,
+0.54207028552814762,
+0.51329879827914859,
+0.50420524418021551,
+0.50132980833995522,
+0.50042052211036525,
+0.50013298076087254,
+0.50004205220872366
80rprecision
= precision(
0._RKH)
/ 2
83exprange
= [(i, i
= -rprecision, rprecision)]
85-16,
-15,
-14,
-13,
-12,
-11,
-10,
-9,
-8,
-7,
-6,
-5,
-4,
-3,
-2,
-1,
+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10,
+11,
+12,
+13,
+14,
+15,
+16
87+0.999999999999996373585417699686748847,
+0.999999999999966038439269991422471636,
+0.999999999999683410243629898865133795,
+0.999999999997064360945602184660495791,
+0.999999999972946194549337116380045088,
+0.999999999752487796450119202118859619,
+0.999999997755136475997589056179272555,
+0.999999979853950029064322113904329775,
+0.999999821565364946706359216161737009,
+0.999998445913190763809082249812063593,
+0.999986761790910335167378117922698844,
+0.999890648699043670145241732485521290,
+0.999137041868993400061435556832101876,
+0.993687646708860290206558750403283676,
+0.960347423521509198326882715453714384,
+0.827551759585850541450312389744143485,
+0.632120558828557678404476229838539127,
+0.542070285528147791685845370654762642,
+0.513298798279148664857314256560736836,
+0.504205244180215508503777843602118862,
+0.501329808339955200382742251299851386,
+0.500420522110365176693312579043826337,
+0.500132980760872591244322817503206681,
+0.500042052208723698333756164784025937,
+0.500013298076014119871248917592827104,
+0.500004205220870056962418526621128081,
+0.500001329807601338847708467065353556,
+0.500000420522087003383370379357918933,
+0.500000132980760133811631428649428437,
+0.500000042052208700336024166457325569,
+0.500000013298076013381090003446869344,
+0.500000004205220870033600103774254030,
+0.500000001329807601338108927205268918
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
12label = [
r"shape: $\kappa = 1.0$"
13 ,
r"shape: $\kappa = 2.5$"
14 ,
r"shape: $\kappa = 5.0$"
17pattern =
"*." + kind +
".txt"
18fileList = glob.glob(pattern)
21 df = pd.read_csv(fileList[0], delimiter =
" ")
23 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
26 for i
in range(1,len(df.values[0,:]+1)):
28 plt.plot( df.values[:, 0]
33 plt.xticks(fontsize = fontsize - 2)
34 plt.yticks(fontsize = fontsize - 2)
35 ax.set_xlabel(
"x", fontsize = fontsize)
36 ax.set_ylabel(
"Regularized Lower\nIncomplete Gamma Function", fontsize = fontsize)
38 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
39 ax.tick_params(axis =
"y", which =
"minor")
40 ax.tick_params(axis =
"x", which =
"minor")
48 plt.savefig(fileList[0].replace(
".txt",
".png"))
52 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 124 of file pm_mathGamma.F90.