Download B.3 The Beta Function

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Chain rule wikipedia , lookup

Pi wikipedia , lookup

Fundamental theorem of calculus wikipedia , lookup

Distribution (mathematics) wikipedia , lookup

Multiple integral wikipedia , lookup

Function of several real variables wikipedia , lookup

Transcript
Appendix B: The Gamma and Beta Functions and Distributions
This appendix serves as an introduction to the gamma and beta functions. These are special
functions that find wide applications in science and engineering. They are also used in probability
and in the computation of certain integrals.
B.1 The Gamma Function
The gamma function, denoted as Γ(n), is also known as generalized factorial function. It is defined as
Get MathML
and this improper[*] integral converges (approaches a limit) for all n > 0.
We will derive the basic properties of the gamma function and its relation to the well known
factorial function
Get MathML
We will evaluate the integral of (B.1) by performing integration by parts using the relation
Get MathML
Letting
Get MathML
we get
Get MathML
Then, with (B.3), we write (B.1) as
Get MathML
With the condition that n > 0, the first term on the right side of (B.6) vanishes at the lower limit, that
is, for x = 0. It also vanishes at the upper limit as x → ∞. This can be proved with L' Hôpital's rule[*]
by differentiating both numerator and denominator m times, where m ≥ n. Then,
Get MathML
Therefore, (B.6) reduces to
Get MathML
and with (B.1) we have
Get MathML
By comparing the two integrals of (B.9), we see that
Get MathML
or
Get MathML
It is convenient to use (B.10) for n < 0, and (B.11) for n > 0.
From (B.10), we see that Γ(n) becomes infinite as n → 0.
For n = 1, (B.1) yields
Get MathML
Thus, we have derived the important relation,
Get MathML
From the recurring relation of (B.11), we obtain
Get MathML
and general
Get MathML
The formula of (B.15) is a very useful relation; it establishes the relationship between the Γ(n)
function and the factorial n!.
We must remember that, whereas the factorial n! is defined only for zero (recall that 0! = 1) and
positive integer values, the gamma function exists (is continuous) everywhere except at 0 and
negative integer numbers, that is, −1, −2, −3, and so on. For instance, when n = −0.5, we can find
Γ(−0.5) in terms of Γ(0.5), but if we substitute the numbers 0, −1, −2, −3 and so on in (B.11), we get
values which are not consistent with the definition of the Γ(n) function, as defined in that relation.
Stated in other words, the Γ(n) function is defined for all positive integers and positive fractional
values, and for all negative fractional, but not negative integer values.
We can use the MATLAB gamma(n) function to plot Γ(n) versus n. This is done with the code below
that produces the plot shown in Figure B.1.
n=-4: 0.05: 4; g=gamma(n); plot(n,g); axis([-4 4 -6 6]); grid;
title('The Gamma Function'); xlabel('n'); ylabel('Gamma(n)')
Figure B.1: Plot of the gamma function
Figure B.1 shows the plot of the function Γ(n) versus n.
Numerical values of Γ(n) for 1 ≤ n ≤ 2, can be found in math tables, but we can use (B.10) or (B.11) to
compute values outside this range. Of course, we can use MATLAB to find any valid values of n.
Example B.1
Compute:
Get MathML
Solution:
From (B.11),
Get MathML
Then,
Get MathML
and from math tables,
Get MathML
Therefore,
Get MathML
From (B.10),
Get MathML
Then,
Get MathML
and from math tables,
Get MathML
Therefore,
Get MathML
From (B.10),
Get MathML
Then,
Get MathML
and using the result of (b),
Get MathML
We can verify these answers with MATLAB as follows:
a=gamma(3.6), b=gamma(0.5), c=gamma(-0.5)
a=
3.7170
b=
1.7725
c=
-3.5449
Excel does not have a function which evaluates Γ(n) directly. It does, however, have the
GAMMALN(x) function. Therefore, we can use the =EXP(GAMMALN(n)) function to evaluate Γ(n) at
some positive value of n. But because it first computes the natural log, it does not produce an
answer if n is negative as shown in Figure B.2.
Figure B.2: Using Excel to find Γ(n).
Example B.2
Prove that when n is a positive integer, the relation
Get MathML
is true.
Proof:
From (B.11),
Get MathML
Then,
Get MathML
Next, replacing n with n − 1 on the left side of (B.18), we get
Get MathML
Substitution of (B.19) into (B.18) yields
Get MathML
By n repeated substitutions, we get
Get MathML
and since Γ(1) = 1, we have
Get MathML
or
Get MathML
Example B.3
Use the definition of the Γ(n) function to compute the exact value of Γ(1/2)
Solution:
From (B.1),
Get MathML
Then,
Get MathML
Letting
Get MathML
we get
Get MathML
or
Get MathML
By substitution of the last three relations into (B.25), we get
Get MathML
Next, we define Γ(1/2) as a function of both x and y, that is, we let
Get MathML
Get MathML
Multiplication of (B.27) by (B.28) yields
Get MathML
Now, we convert (B.29) to polar coordinates by making the substitution
Get MathML
and by recalling that:
the total area of a region is found by either one of the double integrals
Get MathML
from differential calculus
Get MathML
Then,
Get MathML
We observe that as x → ∞ and y → ∞,
Get MathML
Substitution of (B.30), (B.33) and (B.34) into (B.29) yields
Get MathML
and thus, we have obtained the exact value
Get MathML
Example B.4
Compute:
Get MathML
Solution:
Using the relations
Get MathML
we get:
for n = −0.5,
Get MathML
for n = −1.5,
Get MathML
for n = −2.5,
Get MathML
Other interesting relations involving the Γ(n) function are:
Get MathML
Get MathML
Get MathML
Relation (B.38) is referred to as Stirling's asymptotic series for the Γ(n) function. If n is a positive
integer, the factorial n! can be approximated as
Get MathML
Example B.5
Use (B.36) to prove that
Get MathML
Proof:
Get MathML
or
Get MathML
Therefore,
Get MathML
Example B.6
Compute the product
Get MathML
Solution:
Using (B.36), we get
Get MathML
or
Get MathML
Example B.7
Use (B.37) to find
Get MathML
Solution:
Get MathML
or
Get MathML
or
Get MathML
Example B.8
Use (B.39) to compute 50!
Solution:
Get MathML
We can use MATLAB or Excel as a calculator to evaluate this expression. With MATLAB we type and
execute the expression
sqrt(2*pi*50)*50^50*exp(-50)
ans =
3.0363e+064
This is an approximation. To find the exact value, we use the relation Γ(n + 1) = n! and the MATLAB
gamma(n) function. Then,
gamma(50+1)
ans =
3.0414e+064
We can check this answer with the Excel FACT(n) function, that is, =FACT(50) and Excel displays
3.04141E+64
The Γ(n) function is very useful in integrating some improper integrals. Some examples follow.
Example B.9
Using the definition of the Γ(n) function, evaluate the integrals
Get MathML
Solution:
By definition,
Get MathML
Then,
Get MathML
Let 2x = y; then, dx = dy/2, and by substitution,
Get MathML
Example B.10
A negatively charged particle is α meters apart from the positively charged side of an electric field. It
is initially at rest, and then moves towards the positively charged side with a force inversely
proportional to its distance from it. Assuming that the particle moves towards the center of the
positively charged side, considered to be the center of attraction 0, derive an expression for the time
required the negatively charged particle to reach 0 in terms of the distance α and its mass m.
Solution:
Let the center of attraction 0 be the point zero on the x-axis, as indicated in Figure B.3.
Figure B.3: Sketch for Example B.10
By Newton's law,
Get MathML
where
m = mass of particle
x = distance (varies with time)
k = positive constant of proportionality and the
− sign indicates that the distance x decreases as time t increases.
At t = 0, the particle is assumed to be located on the x-axis at point x = α, and moves towards the
origin at x = 0. Let the velocity of the particle be v. Then,
Get MathML
and
Get MathML
Substitution of (B.42) into (B.40) yields
Get MathML
or
Get MathML
Integrating both sides of (B.44), we get
Get MathML
where C represents the constants of integration of both sides, and it is evaluated from the initial
condition that v = 0 when x = α. Then,
Get MathML
and by substitution into (B.45),
Get MathML
Solving for v2 and taking the square root of both sides we get
Get MathML
Since x decreases as t increases, we choose the negative sign, that is,
Get MathML
Solving (B.49) for dt we get
Get MathML
We are interested in the time required for the particle to reach the origin 0. We denote this time as
T; it is found from the relation (B.51) below, noting that the integration on the right side is with
respect to the distance x where at t = 0, x = α, and at τ = t, x = 0. Then,
Get MathML
To simplify (B.51), we let
Get MathML
or
Get MathML
Also, since
Get MathML
the lower and upper limits of integration in (B.51), are being replaced with 0 and ∞ respectively.
Therefore, we express (B.51) as
Get MathML
Finally, using the definition of the Γ(n) function, we have
Get MathML
Example B.11
Evaluate the integrals
Get MathML
Solution:
From the definition of the Γ(n) function,
Get MathML
Also,
Get MathML
For m > 0 and n > 0, multiplication of (B.56) by (B.57) yields
Get MathML
where u and v are dummy variables of integration. Next, letting u = x2 and v = y2, we get du = 2xdx
and dv = 2ydy. Then, with these substitutions, relation (B.58) it written as
Get MathML
Next, we convert (B.59) to polar coordinates by letting x = ρcosθ and y = ρsinθ Then,
Get MathML
To simplify (B.60), we let ρ2 = w; then, dw = 2ρdρ and thus relation (B.60) is written as
Get MathML
Rearranging (B.61) we get
Get MathML
and this expression can be simplified by replacing 2m − 1 with n, that is, m = (n + 1)/2, and 2n − 1
with 0, that is, n = 1/2. Then, we get the special case of (B.62) as
Get MathML
If, in (B.62), we replace 2m − 1 with 0 and 2n − 1 with m, we get the integral of the sinnθ function as
Get MathML
We observe that (B.63) and (B.64) are equal since m and n can be interchanged. Therefore,
Get MathML
The relations of (B.65) are known as Wallis's formulas.
[*]Improper integrals are two types and these are:
where the limits of integration a or b or both are infinite
where f(x) becomes infinite at a value x between the lower and upper limits of integration
inclusive.
[*]Often, the ratio of two functions, such as
, for some value of x, say a, results in the
indeterminate form
. To work around this problem, we consider the limit
, and we
wish to find this limit, if it exists. L'Hôpital's rule states that if f(a) = g(a) = 0, and if the limit
as x approaches a exists, then,
B.2 The Gamma Distribution
One of the most common probability distributions is the gamma distribution which is defined as
Get MathML
A detailed discussion of this probability distribution is beyond the scope of this book; it will suffice to
say that it is used in reliability and queuing theory. When n is a positive integer, it is referred to as
Erlang distribution. Figure B.4 shows the probability density function (pdf) of the gamma distribution
for n = 3 and β = 2.
Figure B.4: The pdf for the gamma distribution.
We can evaluate the gamma distribution with the Excel GAMMADIST function whose syntax is
=GAMMADIST(x,alpha,beta,cumulative)
where:
 x = value at which the distribution is to be evaluated
 alpha = the parameter n in (B.66)
beta = the parameter β in (B.66)
cumulative = a TRUE / FALSE logical value; if TRUE, GAMMADIST returns the cumulative
distribution function (cdf), and if FALSE, it returns the probability density function (pdf).
Example B.12


Use Excel's =GAMMADIST function to evaluate f(x), that is, the pdf of the gamma distribution if:
a.
b.
Solution:
Since we are interested in the probability density function (pdf) values, we specify the FALSE
condition. Then,
a. =GAMMADIST(4,3,2,FALSE) returns 0.1353
b. =GAMMADIST(7,3,2,FALSE) returns 0.0925
We observe that these values are consistent with the plot of Figure B.4.
B.3 The Beta Function
The beta function, denoted as B(m,n), is defined as
Get MathML
where m > 0 and n > 0.
Example B.13
Prove that
Get MathML
Proof:
Let x = 1 − y; then, dx = −dy. We observe that as x → 0, y → 1 and as x → 1, y → 0. Therefore,
Get MathML
and thus (B.68) is proved.
Example B.14
Prove that
Get MathML
Proof:
We let x = sin2θ; then, dx = 2 sinθ cosθdθ. We observe that as x → 0, θ → 0 and as x → 1, θ → π/2.
Then,
Get MathML
Example B.15
Prove that
Get MathML
Proof:
The proof is evident from (B.62) and (B.70).
The B(m, n) function is also useful in evaluating certain integrals as illustrated by the following
examples.
Example B.16
Evaluate the integral
Get MathML
Solution:
By definition
Get MathML
and thus for this example,
Get MathML
Using (B.71) we get
Get MathML
We can also use the MATLAB beta(m,n) function. For this example,
format rat; % display answer in rational format
z=beta(5,4)
z =
1/280
Excel does not provide a function that computes the B(m, n) function directly. However, we can use
(B.71) for its computation as shown in Figure B.5.
Figure B.5: Computation of the beta function with Excel.
Example B.17
Evaluate the integral
Get MathML
Solution:
Let x = 2v; then x2 = 4v2, and dx = 2dv. We observe that as x → 0, v → 0, and as x → 2, v → 1. Then,
(B.74) becomes
Get MathML
where
Get MathML
Then, from (B.74), (B.75) and (B.76) we get
B.4 The Beta Distribution
The beta distribution is defined as
Get MathML
A plot of the beta probability density function (pdf) for m = 3 and n = 2, is shown in Figure B.6.
Figure B.6: The pdf of the beta distribution
As with the gamma probability distribution, a detailed discussion of the beta probability distribution is
beyond the scope of this book; it will suffice to say that it is used in computing variations in
percentages of samples such as the percentage of the time in a day people spent at work, driving
habits, eating times and places, etc.
Using (B.71) we can express the beta distribution as
Get MathML
We can evaluate the beta cumulative distribution function (cdf) with Excels's BETADIST function
whose syntax is
=BETADIST(x,alpha,beta,A,B)
where:
 x = value between A and B at which the distribution is to be evaluated
 alpha = the parameter m in (B.79)
 beta = the parameter n in (B.79)
 A = the lower bound to the interval of x
 B = the upper bound to the interval of x
From the plot of Figure B.6, we see that when x = 1, f(x, m, n) which represents the probability density
function, is zero. However, the cumulative distribution (the area under the curve) at this point is 100%
or unity since this is the upper limit of the x-range. This value can be verified by
=BETADIST(1,3,2,0,1)
which returns 1.0000.