ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_distGenExpGamma Module Reference

This module contains classes and procedures for computing various statistical quantities related to the GenExpGamma distribution. More...

Data Types

type  distGenExpGamma_type
 This is the derived type for signifying distributions that are of type GenExpGamma as defined in the description of pm_distGenExpGamma. More...
 
interface  getGenExpGammaCDF
 Generate and return the Cumulative Distribution Function (CDF) of the GenExpGamma distribution for an input x within the support of the distribution \(x \in (-\infty,+\infty)\). More...
 
interface  getGenExpGammaLogPDF
 Generate and return the natural logarithm of the Probability Density Function (PDF) of the GenExpGamma distribution. More...
 
interface  getGenExpGammaLogPDFNF
 Generate and return the natural logarithm of the normalization factor of the Probability Density Function (PDF) of the GenExpGamma distribution.
More...
 
interface  setGenExpGammaCDF
 Return the Cumulative Distribution Function (CDF) of the GenExpGamma distribution for an input x within the support of the distribution \(x \in (-\infty,+\infty)\). More...
 
interface  setGenExpGammaLogPDF
 Return the natural logarithm of the Probability Density Function (PDF) of the GenExpGamma distribution. More...
 

Variables

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

Detailed Description

This module contains classes and procedures for computing various statistical quantities related to the GenExpGamma distribution.

Specifically, this module contains routines for computing the following quantities of the GenExpGamma distribution:

  1. the Probability Density Function (PDF)
  2. the Cumulative Distribution Function (CDF)
  3. the Random Number Generation from the distribution (RNG)
  4. the Inverse Cumulative Distribution Function (ICDF) or the Quantile Function

A variable \(X\) is said to be GenExpGamma-distributed if its PDF with location \(-\infty < \log(\sigma) < +\infty\), scale (inverse rate) \(\omega > 0\), and shape \(\kappa > 0\) parameters is described by the following equation,

\begin{equation} \large \pi(x | \kappa, \omega, \log(\sigma)) = \frac{1}{\omega \Gamma(\kappa)} ~ \exp\Bigg( \kappa\bigg(\frac{x - \log(\sigma)}{\omega}\bigg) - \exp\bigg(\frac{x - \log(\sigma)}{\omega}\bigg) \Bigg) ~,~ -\infty < x < \infty \end{equation}

where \(\eta = \frac{1}{\omega \Gamma(\kappa)}\) is the normalization factor of the PDF.
When \(\sigma = 1\), the GenExpGamma PDF simplifies to the form,

\begin{equation} \large \pi(x) = \frac{1}{\omega \Gamma(\kappa)} ~ \exp\Bigg(\kappa \frac{x}{\omega} - \exp\bigg(\frac{x}{\omega}\bigg) \Bigg) ~,~ -\infty < x < \infty \end{equation}

If \((\sigma, \omega) = (1, 1)\), that is, \(x\) is standardized, the GenExpGamma PDF further simplifies to the form,

\begin{equation} \large \pi(x) = \frac{1}{\Gamma(\kappa)} ~ \exp\Bigg(\kappa x - \exp(x) \Bigg) ~,~ -\infty < x < \infty \end{equation}

Setting the shape parameter to \(\kappa = 1\) further simplifies the PDF to the form,

\begin{equation} \large \pi(x) = \exp\Bigg(x - \exp(x)\Bigg) ~,~ -\infty < x < \infty \end{equation}

The parameter \(\log(\sigma)\) determines the horizontal location of the mode of this unimodal GenExpGamma PDF.
While the PDF is always unimodal, the overall height and steepness of the PDF curve are determined by the values of \(\kappa\) and \(\omega\).
In addition, the tails of the PDF are fat, in the sense that the PDF decreases algebraically rather than decreasing exponentially for large values of \(x\).
The term GenExpGamma is shorthand for Exponential-Gamma, and the GenExpGamma distribution is sometimes referred to as the generalized extreme value distribution.
The term also sometimes collectively refers to a number of qualitatively similar probability distributions.
The GenExpGamma distribution is mathematically defined to be the distribution of \(\log(X)\) where \(X\) follows a GenGamma distribution.
GenExpGamma distribution is also significant because of the statistical extreme value theorem, which states that the maximum of a sample of i.i.d. random variables can only converge in distribution to one of three possible distributions,

  1. Gumbel distribution,
  2. Frechet distribution,
  3. Weibull distribution,

all of which are special cases of GenExpGamma distribution.
The GenExpGamma distribution is used in various branches of science to model a number of phenomena, including wind speeds in meteorology and ocean current speeds in ocean engineering.

The CDF of the GenExpGamma distribution over a strictly-positive support \(x \in (0, +\infty)\) with the three (shape, shape, scale) parameters \((\kappa > 0, \omega > 0, \sigma > 0)\) is defined by the regularized Lower Incomplete Gamma function as,

\begin{eqnarray} \large \mathrm{CDF}(x | \kappa, \sigma) & = & P\big(\kappa, \frac{x - \log(\sigma)}{\omega}\big) \\ & = & \frac{1}{\Gamma(\kappa)} \int_0^{\exp(\frac{x - \log(\sigma)}{\omega})} ~ t^{\kappa - 1}{\mathrm e}^{-t} ~ dt ~, \end{eqnarray}

where \(\Gamma(\kappa)\) represents the Gamma function.

Warning
The GenExpGamma distribution is also frequently mistakenly called GenLogGamma , which is an entirely different distribution.
Note
The relationship between the GenExpGamma and GenGamma distributions is similar to that of the Normal and LogNormal distributions.
In other words, a better more consistent naming for the GenExpGamma and GenGamma distributions could have been GenGamma and GenLogGamma distributions, respectively, similar to Normal and LogNormal distributions.
See also
pm_distGamma
pm_distGenGamma
Wolfram Research (2010), GenExpGammaDistribution, Wolfram Language function, https://reference.wolfram.com/language/ref/GenExpGammaDistribution.html (updated 2016)
Benchmarks:


Benchmark :: The runtime performance of getGenExpGammaLogPDF vs. setGenExpGammaLogPDF

1! Test the performance of `getGenExpGammaLogPDF()` vs. `setGenExpGammaLogPDF()`.
2program benchmark
3
4 use iso_fortran_env, only: error_unit
5 use pm_bench, only: bench_type
6 use pm_kind, only: IK, RK, SK
7
8 implicit none
9
10 integer(IK) :: i
11 integer(IK) :: isize
12 integer(IK) :: fileUnit
13 integer(IK) , parameter :: NSIZE = 18_IK
14 integer(IK) , parameter :: NBENCH = 2_IK
15 integer(IK) :: arraySize(NSIZE)
16 real(RK) , allocatable :: Array(:), Point(:)
17 real(RK) :: dummy = 0._RK
18 type(bench_type) :: bench(NBENCH)
19
20 bench(1) = bench_type(name = SK_"setGenExpGammaLogPDF", exec = setGenExpGammaLogPDF , overhead = setOverhead)
21 bench(2) = bench_type(name = SK_"getGenExpGammaLogPDF", exec = getGenExpGammaLogPDF , overhead = setOverhead)
22
23 arraySize = [( 2_IK**isize, isize = 1_IK, NSIZE )]
24
25 write(*,"(*(g0,:,' '))")
26 write(*,"(*(g0,:,' vs. '))") (bench(i)%name, i = 1, NBENCH)
27 write(*,"(*(g0,:,' '))")
28
29 open(newunit = fileUnit, file = "main.out", status = "replace")
30
31 write(fileUnit, "(*(g0,:,','))") "arraySize", (bench(i)%name, i = 1, NBENCH)
32
33 loopOverArraySize: do isize = 1, NSIZE
34
35 write(*,"(*(g0,:,' '))") "Benchmarking with size", arraySize(isize)
36
37 allocate(Array(arraySize(isize)), Point(arraySize(isize)))
38 do i = 1, NBENCH
39 bench(i)%timing = bench(i)%getTiming(minsec = 0.05_RK)
40 end do
41 deallocate(Array, Point)
42
43 write(fileUnit,"(*(g0,:,','))") arraySize(isize), (bench(i)%timing%mean, i = 1, NBENCH)
44
45 end do loopOverArraySize
46
47 write(*,"(*(g0,:,' '))") dummy
48 write(*,"(*(g0,:,' '))")
49
50 close(fileUnit)
51
52contains
53
54 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 ! procedure wrappers.
56 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57
58 subroutine setOverhead()
59 call initialize()
60 call finalize()
61 end subroutine
62
63 subroutine initialize()
64 call random_number(Point)
65 end subroutine
66
67 subroutine finalize()
68 dummy = dummy + Array(1)
69 end subroutine
70
71 subroutine setGenExpGammaLogPDF()
72 block
74 call initialize()
75 call setGenExpGammaLogPDF(Array, Point)
76 call finalize()
77 end block
78 end subroutine
79
80 subroutine getGenExpGammaLogPDF()
81 block
83 call initialize()
84 Array = getGenExpGammaLogPDF(Point)
85 call finalize()
86 end block
87 end subroutine
88
89end program benchmark
Generate and return an object of type timing_type containing the benchmark timing information and sta...
Definition: pm_bench.F90:574
Generate and return the natural logarithm of the Probability Density Function (PDF) of the GenExpGamm...
Return the natural logarithm of the Probability Density Function (PDF) of the GenExpGamma distributio...
This module contains abstract interfaces and types that facilitate benchmarking of different procedur...
Definition: pm_bench.F90:41
This module contains classes and procedures for computing various statistical quantities related to t...
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
This is the class for creating benchmark and performance-profiling objects.
Definition: pm_bench.F90:386

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Postprocessing of the benchmark output
1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4import pandas as pd
5import numpy as np
6
7import os
8dirname = os.path.basename(os.getcwd())
9
10fontsize = 14
11
12df = pd.read_csv("main.out", delimiter = ",")
13colnames = list(df.columns.values)
14
15
18
19ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
20ax = plt.subplot()
21
22for colname in colnames[1:]:
23 plt.plot( df[colnames[0]].values
24 , df[colname].values
25 , linewidth = 2
26 )
27
28plt.xticks(fontsize = fontsize)
29plt.yticks(fontsize = fontsize)
30ax.set_xlabel(colnames[0], fontsize = fontsize)
31ax.set_ylabel("Runtime [ seconds ]", fontsize = fontsize)
32ax.set_title(" vs. ".join(colnames[1:])+"\nLower is better.", fontsize = fontsize)
33ax.set_xscale("log")
34ax.set_yscale("log")
35plt.minorticks_on()
36plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
37ax.tick_params(axis = "y", which = "minor")
38ax.tick_params(axis = "x", which = "minor")
39ax.legend ( colnames[1:]
40 #, loc='center left'
41 #, bbox_to_anchor=(1, 0.5)
42 , fontsize = fontsize
43 )
44
45plt.tight_layout()
46plt.savefig("benchmark." + dirname + ".runtime.png")
47
48
51
52ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
53ax = plt.subplot()
54
55plt.plot( df[colnames[0]].values
56 , np.ones(len(df[colnames[0]].values))
57 , linestyle = "--"
58 #, color = "black"
59 , linewidth = 2
60 )
61for colname in colnames[2:]:
62 plt.plot( df[colnames[0]].values
63 , df[colname].values / df[colnames[1]].values
64 , linewidth = 2
65 )
66
67plt.xticks(fontsize = fontsize)
68plt.yticks(fontsize = fontsize)
69ax.set_xlabel(colnames[0], fontsize = fontsize)
70ax.set_ylabel("Runtime compared to {}".format(colnames[1]), fontsize = fontsize)
71ax.set_title("Runtime Ratio Comparison. Lower means faster.\nLower than 1 means faster than {}().".format(colnames[1]), fontsize = fontsize)
72ax.set_xscale("log")
73#ax.set_yscale("log")
74plt.minorticks_on()
75plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
76ax.tick_params(axis = "y", which = "minor")
77ax.tick_params(axis = "x", which = "minor")
78ax.legend ( colnames[1:]
79 #, bbox_to_anchor = (1, 0.5)
80 #, loc = "center left"
81 , fontsize = fontsize
82 )
83
84plt.tight_layout()
85plt.savefig("benchmark." + dirname + ".runtime.ratio.png")

Visualization of the benchmark output

Benchmark moral
  1. The procedures under the generic interface getGenExpGammaLogPDF are functions while the procedures under the generic interface setGenExpGammaLogPDF are subroutines.
    From the benchmark results, it appears that the functional interface performs slightly less efficiently than the subroutine interface when the input x size is small.
    Otherwise, the difference appears to be marginal and insignificant in most practical situations.
Test:
test_pm_distGenExpGamma


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.

  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, Oct 16, 2009, 11:14 AM, Michigan

Variable Documentation

◆ MODULE_NAME

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

Definition at line 139 of file pm_distGenExpGamma.F90.