0% found this document useful (0 votes)
60 views17 pages

Week 8 Gamma - Exponential

The gamma distribution is a two-parameter distribution that generalizes the exponential distribution and offers more flexibility in modeling right-skewed quantities. The gamma distribution has a shape parameter α > 0 and a scale parameter β > 0. It has a probability density function defined in terms of α and β. The mean and variance of a gamma-distributed random variable X are E(X) = αβ and V(X) = αβ2, respectively. The gamma distribution can model contexts involving waiting times or processes with Poisson arrivals better than the exponential distribution.

Uploaded by

Qwerty Qwerty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views17 pages

Week 8 Gamma - Exponential

The gamma distribution is a two-parameter distribution that generalizes the exponential distribution and offers more flexibility in modeling right-skewed quantities. The gamma distribution has a shape parameter α > 0 and a scale parameter β > 0. It has a probability density function defined in terms of α and β. The mean and variance of a gamma-distributed random variable X are E(X) = αβ and V(X) = αβ2, respectively. The gamma distribution can model contexts involving waiting times or processes with Poisson arrivals better than the exponential distribution.

Uploaded by

Qwerty Qwerty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

STA 247

Probability with Computer Applications

! "#$ %&'() + ,- )- *
)-./0
Professor K. H. Wong
*
&(

4 .-567-/.
1/23 8 * -136* &6

"* 9):.&- ;

53 <77 * ()/') = >?@A * 1B

Week 8 - November 1

October 30, 2021 1 / 13


Learning Outcomes

By the end of this video, you should be able to...


Explain the relation between Poisson arrivals, exponential, and
gamma distributions
Identify contexts in which the random variable should be modeled
with a Poisson/exponential/gamma distribution
Recognize quantities that are exponentially or gamma distributed,
their properties, and use them appropriately in applications (including
problems involving Poisson arrivals)
Comfortably switch between and use ⁄ and ◊, and describe how these
two parameters differ 1 )
'/)3 (C/73

D /E3623 -% /E3'/23 7362)H I.:'/)&-6


F G

* .&(C'3)3
.&(C'3)3 * -CC:''36C3( 13' * -CC:''36C3 J

13' * C-6)&6:-:(

&6)3'E/7 J

October 30, 2021 2 / 13


Gamma Distribution
The exponential distribution that you learned, which can sometimes be used to
model wait time, is quite limiting in its shape. The related gamma distribution
that you’re about to learn about is defined by two parameters which offers
more options and flexibility in modeling quantities that tend to be right-skewed:
%* GK J *
%O
* K * N J
I% P- J
L
*
M%1 G
3)1C
O
* K Q*-
O

%* 3R J N
S .3%&63.
1/'/B3)3'
B3/6
T0

S )
-%
1/'/B3)3'( U
.&()'&T:)&-6
,/BB/

Image from Wikipedia

October 30, 2021 3 / 13


Common Continuous RV - Gamma

Gamma Distribution
An gamma distribution with shape parameter – > 0 and scale parameter
— > 0 for a continuous random variable X has probability density function: S

XY
V

SP J
V

*
,/BB/ %:6C)&-6
V

V
.&()'&T:)&-6 )
Y %:6C)&-6/7 1/')0 * 2/BB/ *

1
W
] x
x –≠1 e ≠ — , x > 0 Q* -

f (x ) = (–) — –
[ O

0, elsewhere
@@
O

3R1 \1 J GN *

;
X has mean and variance:
C-6()/6)(

=)%.Z%CR061[3O#>UR
B/7&26&62
*
* +
* 36(:'3( * )H3 * H/( * )-)/7 * /'3/ * \[
.36(&)0

E (X ) = –— and V (X ) = –— 2
\ * I

In such cases, we define X as: X ≥ (–, —).

Note: The MMSA textbook uses the above parameterizations of (–, —), while
the PAR textbook uses the parameterizations (–, ⁄) resulting in
< V

RU *N

f (x ) = ⁄N x (–)e N for x > 0


– –≠1 ≠⁄x &6

'/)3

!
*
/
]
* \

October 30, 2021 4 / 13


Common Continuous RV - Gamma ^ ^

U(&F&MI?(

fg
OU
<
Notes: V
/ _ ` / _ C- U
U
*

1. (–) is the gamma function defined by:

NVS?b
⁄ a Œ

.R0
(–) = x –≠1 e ≠x dx ?^
U

U U

0 O
2. For – > 1, (–) = (– ≠ 1) (– ≠ 1) C-B1:)3
63

'3C:'(&E370
)- * c
*

2 \[ R<
W
O

3
dd

3. For – œ Z+ , (–) = (– ≠ 1)!


Ô D $;
\
> *
\
*e

4. Fun fact: (1/2) = fi


O

W * 5-6<) * .3'&E3* )H&(

5. When – = 1: gamma(1, —) = exp(—) i.e. the exponential distribution


is a special case of the gamma distribution (note: — is the scale
6EB

parameter, not rate – recall scale ◊ and rate ⁄ from exponential


$\
distributions)
&6.31 G &U &U /6.
1/'/B3)3'
* *
* )H3*
O

/77 * H/'3 (/B3


&U&. J
2 &.36)&C/770 .&()'&T:)3.
6. The sum of n independent Exp(◊) random variables
T = X1 + X2 + .... + Xn , where Xi ≥ Exp(◊), results in a gamma
random variable with T ≥ (n, ◊)W
-6
1

7. The CDF of (–, —) has no closed form when –, — ”œ Z+ , making it


difficult to compute probabilities without R
October 30, 2021 5 / 13
Gamma Distribution: When to Use?

In the context of our course:


A continuous RV will be explicitly stated as having a gamma
distribution
The continuous RV relates to the random interval between Poisson
arrivals and/or is a sum of identical exponentially distributed random
variables

October 30, 2021 6 / 13


Gamma Distribution: E(X) and V(X)

P371
I% * K * L * ,/BB/ * J

Let’s derive the expected value of Gamma:

hq.h
KM
i
* h

]81/opi3
k
< O

%/7(3 3 K Q* -

j
8
8

M V* <
%< *< * V .O V

- * 37(35H3'3
* 8
U

8 <

m3/ %:6C)&-6 * .3% ?

-%
V
!
n.R ,/BB/
*< *

%d
O

l
\
3

h.h
t-(3))3
U
O

8 Ss J * \

tn
O

IS O
.&)
u SP J * \
* G/ O

) J SC/ O

$ %-' * / Q *I
*
O
()':C):'3 -% 2/BB/ S-6)& J * \
* h * S3/ 8
2/BB/
D f)7 &% J
r
n.R
V
n.R O@
V
/)3
* *
MP J (&.3
O
O

21/ R71
* 73)
O

0
O

*
O

2-63
O

1&1/

%)1U&10&3O)1.2.RO3.0F%,/BB/GR)7
V \
/
1 O
* SG
v0
C<
*
\
(&B&7/' * )- J * < *
O

^V]nIh
O

SP O@@
J
O
O

R1
O

\o ;lw nS
O

l
.0
O
3

8
0
V * /) * < <

I 0-s3
M [% \ *
2-63
O

S SH) ! * $\ * ZSP J
8
2
O

)3/ )
R1 \ *
\
\ *

The variance derivation will be left as an exercise – Try it!


8

October 30, 2021 7 / 13


Gamma Distribution: Examples

Gamma Uses
The Gamma distribution is often used to measure waiting times such as
time until “death”. Notice also that by setting – = 1, you get the
Exponential distribution.
.&(C'3)3

Example 1 The number of service requests fulfilled by a technician at a


support centre is Poisson distributed with an average of 10 per workday (8
hours). How would you model the random time it takes to complete two
W * C-6)&6:-:(
O

unrelated and independent service requests by this technician? What is the


O

average and variance in completion time?


%-' * S )&B3 * &6 * H-:'( * &)H * )/(s
[3) ? *
*
\

<

+ * y7)&s-
K* * H-:'( )- *x S&6 *
3R1
G A\A xJ
*
(3'E&C3
'3z:3()(
8

* )- * 13' * x
V

+ *
M%%& J * OA
\

H-5( I P--
* 13' * '3z:3()
O

{ F
O

*
*
\
/E3'/23 O

O
l
O

N&(H& #T) Ye
* 13'
*
/E3'/23 -% * &6.3%
\

-%*
U

2:B

y'7)p
W
JJ

@A\AUx
O
3R1
S * * S& * Sp
S-)/7 )&B3 )
O
\
O
*

e8A\AUx IS
* MGS$SMGS| J
<
*
OAxhe\@U}
MGS J O
O
MGS 8 )H3 J \

S O
,/BB/ [. O

J
~GS J S7 &( * &H.31 Se
O

yGS J \ * yGS 8
)H3 J* \ * 8
)
J *

+MGSJ\K1\eR-Ux\FS0
O V
?
* AUx cA8x

J yGS e@>eOOehAUx\@Uex
<
* *
\
* ehA8x \ * @Uex \

October 30, 2021 8 / 13


R Code Computation - Gamma

As mentioned earlier, the CDF of a gamma random variable has no closed


form solution. To calculate probabilities, we can use R statistical software.
D M7 I)
5H36 * /
8 %

Given X ≥ (–, —)... d


1 2/BB/

P(X Æ k) is computed with pgamma(k, shape= –, scale


I = —). You
MUST indicate scale since Gamma can be written as (shape, scale)
1
or (shape, rate = scale = —1 )
\

October 30, 2021 9 / 13


R Code Computation - Gamma

As mentioned earlier, the CDF of a gamma random variable has no closed


form solution. To calculate probabilities, we can use R statistical software.

Given X ≥ (–, —)...


P(X Æ k) is computed with pgamma(k, shape= –, scale = —). You
MUST indicate scale since Gamma can be written as (shape, scale)
1
or (shape, rate = scale = —1 )
To simulate n data values from a gamma distribution, we use
rgamma(n, shape= –, scale = —)

October 30, 2021 9 / 13


Compute by Hand & R - Gamma Example
Example 2 Returning to the previous example, find the probability that two
service requests takes more than 3 hours to fulfill. n Y@e J * * V G$ ;
m3
*
\o
O

O
)
O O

-
%7)
Q
*

Iz
)
v xJ
* J*
O

+ 8
N
O

G/'
e\AUxeOOAU}Z
O

S * ,/BB/
1
O
U

L
8

n$•
n7 @Y> J \ * /:/:/.3' <
O
b <(

% I) J
l ) 3 3
\
8 * -

%'-B * > * )- *
&6%&6&)0 8

td %%)).)
$
I
\
\
OZAUx
* V
O

x 3
<

V
)

2d
* .)

)% M<
\
)3

(2m [&(/
)H&(

?^ <(
O

(3
<
* )-
:.&&&))%
* *<

%33
U U
O

<
U U
/)
l |3
O
)&B3(
AUx
53
* 23) -
: O
A
.&%% &6)32'/)3

J
* V *V €
)H&( od
l D
<
\ O

O
- 8 3
-')3
O

\ \

* V *V € * V *V

xJ
O

D
O

<
AU@@@Y * @@8@Y}
O

-'

I%%0 AUx@> J
O

] I J
\ O
O
3 O
AUx 3
-

73%) )/&73. * \
* •J
>J 12/BB/7 > 9C/73
e AUx
nIS
O
O

Q +
O

8 8 8

nGS M> J (-/s OAUx J


I \
* I O

12/:'B/7 >8e *
O

October 30, 2021 10 / 13


Compute by Hand & R - Gamma Example
Example 2 Returning to the previous example, find the probability that two
service requests takes more than 3 hours to fulfill.

Using R to compute P(T Æ 3):

October 30, 2021 10 / 13


Compute by Hand & R - Gamma Example
Example 2 Returning to the previous example, find the probability that two
service requests takes more than 3 hours to fulfill.

Using R to compute P(T Æ 3):

R code
pgamma ( 3 , s h a p e =2 , s c a l e = 0 . 8 )
[ 1 ] 0.882907

October 30, 2021 10 / 13


Compute by Hand & R - Gamma Example
Example 2 Returning to the previous example, find the probability that two
service requests takes more than 3 hours to fulfill.

Using R to compute P(T Æ 3):

R code
pgamma ( 3 , s h a p e =2 , s c a l e = 0 . 8 )
[ 1 ] 0.882907

P(T > 3) = 1 ≠ 0.882907 = 0.1117093


October 30, 2021 10 / 13
Gamma Example
MGK J R1
O

&(
,/BB/ s
1J
<
8 + * ECR J \ *
R1

Example - Exact vs Chebyshev’s Inequality 0&6


(3C-6.( J *

Suppose that the distribution of length of TikTok videos is approximately gamma


distributed with parameters – = 2, — = 6. (Question: why only
“approximately”?). According to Chebyshev’s inequality, what interval of video
lengths make up 80% of TikTok videos? Find the exact probability of the
computed interval. MGS J R1 \
*
O
O
@e 73) *
S * \ * '/6.-B

*
*

)&B3*
S&sO)-s
&6 * (3C-6.(
* N* E&.3-
OxUZ• * (3C-6.(
eh}e
*
<

*
* Ye U

yGS
< * \
J *
R1
O
\

SL * P3
O

1 \$
,/BB/ 8

GH3T0(H3E‚
* I63z:/7&)0 MR/C) S Q*-

O
O * V
T-7)
V* V
O

J YAUx * I
] J
\[ )
*
#I s- nIS O>AU•Y 3
O

*
\
/
nG I S O

I
A8x * \
* I O
* V T
.)
O

s
<

F 3 * 3
@>AU•Y
\

] O

O - U
<

) <*
*V }
MI
O

•( ;
O

ƒ< * T33
O
(3
)7T
O \ U

/)
O

f'&s * E/'&/6) % 3
.&()' 5&)H

I)
* 8
B/0 „„\eOe>}@
O )/
7&3 5&)H&6 T3
-:)C-B3( * 8
O

73/() * (-0 U

-% *
OAU•}ZY -' •}UZYb
!
O O PT
- >} * 3
)H3
-% *
9$ * B3/6 U

•}UZYb /77 S&s * S-s E&.3-(


-% * * * /'3

@e * I SMSM *
\
D O

}U•Y >AU•Yt *
\
8
*
T3)5336 * - * )- * >A•Y * (3C-6.(
7-62 U

>AU•Y„
E&.3-( /) * B-() 7-62
f) * 73/() xA@ -% * S&s * S-s * /C3 *
*
U

October 30, 2021 11 / 13


Gamma Example
Example - Exact vs Chebyshev’s Inequality
Suppose that the distribution of length of TikTok videos is approximately gamma
distributed with parameters – = 2, — = 6. (Question: why only
“approximately”?). According to Chebyshev’s inequality, what interval of video
lengths make up 80% of TikTok videos? Find the exact probability of the
computed interval.
B&(
)-
+
U*
/

8
o

$
V

n
|

October 30, 2021 12 / 13


Practice!

Suppose the driving distance before maintenance is required can be


modeled with an exponential distribution, D ≥ exp(10) where D is
measured in 1000 km. Oliver owns two cars, and is interested in modeling
the combined distance he can get between his two cars before they both
require maintenance.
a) Define an appropriate random variable for each of his two cars. Define
a new random variable Y for the combined distance. What
distribution does Y have?
b) What is the probability that the combined distance will exceed 30,000
km?
c) Think about and explain briefly why we need to have a combined
random variable Y to answer (b). That is, why can we not work with
the distribution of the individual cars? Hint: What would the cases
look like?

October 30, 2021 13 / 13

You might also like