CALCULUS II: INTEGRATION
Gamma and beta functions
Data Science Institute, Hasselt University
Contents
Theory . . . . . . . . . . . . . . . . . . . . 1
Examples . . . . . . . . . . . . . . . . . . 3
R-software . . . . . . . . . . . . . . . . . . 3
Exercises . . . . . . . . . . . . . . . . . . . 4
Advanced: Statistical Applications . . 4
Acknowledgment . . . . . . . . . . . . . 4
Solutions Exercises . . . . . . . . . . . . 5
Theory
Gamma function
The gamma function is denoted by the symbol Γ. The Γ function is a generalization of the
factorial function to real and complex numbers. In this module, attention is limited to positive
real numbers. Let x be a positive real number, then Γ(x) (Figure 1) is defined by
Z ∞
Γ(x) = y x−1 e−y dy
0
100
80
60
gamma(x)
40
20
0
0 1 2 3 4 5
Figure 1: Gamma function.
1
Data Science Institute, Hasselt University
The fundamental property of the Γ function is
Γ(x + 1) = xΓ(x)
For every positive integer n
Γ(n) = (n − 1)!
Beta function
The beta function, denoted by B. For a>0 and b>0, the beta function (Figure 2) is defined by
Z 1
B(a, b) = z a−1 (1 − z)b−1 dz
0
Figure 2: Bivariate beta function.
B(a, b) can be expressed as a composition of Γ functions as
Γ(a)Γ(b)
B(a, b) =
Γ(a + b)
A useful result of the B function is that B(a, b) = B(b, a).
The beta function can be generalized to a function with more than two arguments as
Qk
i=1 Γ(αi )
B(α1 , α2 , ..., αk ) = Pk
Γ( i=1 αi )
2
Data Science Institute, Hasselt University
Examples
Examples gamma function
i. Calculate Γ(1)
Z ∞
Γ(1) = y 1−1 e−y dy
0
Z ∞
= e−y dy
0
∞
= −e−y
0
= −(0 − 1)
= 1
ii. Calculate Γ(2)
Γ(2) = 1.Γ(1)
= 1.1
= 1
Examples beta function
i. Calculate B(2, 3)
Γ(2)Γ(3)
B(2, 3) =
Γ(5)
1!2!
=
4!
2
=
24
1
=
12
ii. Calculate B(3, 2)
Γ(3)Γ(2)
B(3, 2) =
Γ(5)
..
.
1
=
12
R-software
R is a free software environment for statistical computing and graphics. It compiles and runs on
a wide variety of UNIX platforms, Windows and MacOS. You can download this software for
free from the website (https://www.r-project.org/). You can also use the basic functions of
R without installing the software using R-Fiddle (http://www.r-fiddle.org/). R-Fiddle is a
tool that provides you with a free and powerful environment to write and run R-code right inside
your browser.
3
Data Science Institute, Hasselt University
Gamma function
> # gamma(x)
> gamma(2)
[1] 1
>
> gamma(0.5)
[1] 1.772454
>
> # gamma(x) over range of x
> x = seq(from=0.01, to=5, by=0.01)
> plot(x, gamma(x), type="l", main="Gamma function")
Beta function
> # beta(a,b)
> beta(2,3)
[1] 0.08333333
>
> beta(0.6,1.2)
[1] 1.468063
Exercises
Exercises indicated with a ⋆ are preferable solved using R or R-Fiddle.
1. Show that:
i. Γ(x + 1) = xΓ(x);
ii. hence show that for n ∈ N, Γ(n + 1) = n!.
R∞
2. Calculate: 0 y 8 e−y dy (⋆)
3. Show that: B(a, b) = B(b, a)
4. Derive E(X) given that:
i. X ∼ Gamma(α, β);
ii. X ∼ Beta(α, β).
Advanced: Statistical Applications
• The gamma function is used in the definition of several probability distributions, e.g.,
Student’s t, Gamma and χ2 distributions.
• The beta function is used in the definition of the beta distribution; the multivariate beta
function is used in the definition of the Dirichlet distribution.
Acknowledgment
This contribution was written by M. Aerts, T. Ganyani, L. Garcia Barrado & Y. Vandendijck.
Last update: October, 2023
4
Data Science Institute, Hasselt University
Solutions Exercises
1. Show that:
i. Γ(x + 1) = xΓ(x)
Z ∞
Γ(x + 1) = y x+1−1 e−y dy
0
Z ∞
= y x e−y dy
0
dv
integrating by parts: letting u = y x and = e−y
dx
∞ Z ∞
Γ(x + 1) = −y x e−y − xy x−1 (−e−y )dy
0
Z ∞ 0
= x y x−1 e−y dy
0
= xΓ(x).
ii. hence show that for n ∈ N, Γ(n + 1) = n!
if n ∈ N then, Γ(n + 1) = nΓ(n)
= n(n − 1)Γ(n − 1)
..
.
= n(n − 1)(n − 2)Γ(n − 2) . . . 1
= n!
R∞
2. Calculate: 0
y 8 e−y dy (⋆)
Z ∞
y 8 e−y dy = Γ(9)
0
= 40320 (using R)
3. Show that: B(a, b) = B(b, a)
Z 1
let z = 1 − w, B(a, b) = z a−1 (1 − z)b−1 dz
0
Z 1
= (1 − w)a−1 wb−1 dw
0
Z 1
= wb−1 (1 − w)a−1 dw
0
= B(b, a)
5
Data Science Institute, Hasselt University
4. Derive E(X) given that:
i. X ∼ Gamma(α, β)
Z ∞
E(X) = xf (x)dx
Z0 ∞
β α α−1 −βx
= x x e dx
0 Γ(α)
∞
βα
Z
= x(α+1)−1 e−βx dx
Γ(α) 0
using the substitution: y = βx
Z ∞
β α−1
E(X) = y (α+1)−1 e−y dy
β α Γ(α) 0
β α−1
= Γ(α + 1)
β α Γ(α)
α
= .
β
ii. X ∼ Beta(α, β)
Z 1
E(X) = xf (x)dx
0
1
xα−1 (1 − x)β−1
Z
= x dx
0 B(α, β)
Z 1
1
= x(α+1)−1 (1 − x)β−1 dx
B(α, β) 0
1
= B(α + 1, β)
B(α, β)
α
= .
α+β