Distributions2 PPT

You might also like

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 24

© 2008    Winton

Distributions (2)
© 2008    Winton
2

IV. Triangular Distribution


•Known values
–The minimum (a)
–The mode (b - the most likely value of the pdf)
–The maximum (c)
probability density function
(area under the curve = 1);
the area under the triangle (1)
is half the area of its
bounding box which is h(c-a)
f(x)

2
h=
c -a
a bcx
© 2008    Winton
3

pdf for Triangular Distribution

• The pdf is given by


2(x - a) h
for a =x = b (slope = )
(c - a)(b - a) b-a
f(x) =
- 2(x - c) - h
for b =x = c (slope = )
(c - a)(c - b) c-b

=      0 otherwise
© 2008    Winton
4

Expected Value

• The expected value is given by


8 b c
2(x - a) 2(c - x) a + b+ c
E(X) = x ·f(x)dx = · xdx + · xdx =
(c - a)(b - a) (c - a)(c - b) 3
-8 a b
• Derivation: with a little work the integrals evaluate to
2b3 - 3ab2 + a3 c3 - 3cb2 + 2b3 a3 (c - b) + b3 (a - c) + c3 (b - a)
E(X) = h · + =
6(b - a) 6(c - b) 3(c - a)(b - a)(c - b)
(a + b + c)(c - a)(b - a)(c - b) a + b + c
= =
3(c - a)(b - a)(c - b) 3
© 2008    Winton
5

About mean, mode, and median


• For a discrete sample, measures of centrality that are typically
determined are the mean, the mode, and the median
•The mean is the average value of the sample and corresponds to E(X)
•The mode corresponds to the maximum value of the pdf
– When working with a sample, it is necessary to resort to a histogram
(which can be tricky) to estimate the mode of the underlying pdf
•The median simply corresponds to that point at which half of the area
under the curve is to the left and half is to the right
– The triangular distribution is typically employed when not much is known
about the distribution, but the minimum, mode, and maximum can be
estimated.
Sampling From the Triangular
© 2008    Winton
6

Distribution
rsample
• Again this means solving x= f(z)dz
-8
for rsample given a random probability x
• Since f(z) is piecewise continuous, its distribution function
F(t) is given by
0 for t = a
t
Left side
f(z)dz for a <t = b integral
t
F(t) = f(z)dz = a
c
-8 1 - f(z)dz for b =t < c Right side
integral
t
1 for t = c
© 2008    Winton
7

Left and Right Side Integrals

• For left side a = rsample = b


rsample rsample rsample
2(z - a) z2 - 2az (rsample - a)2
x= f(z)dz = dz = =
(b - a)(c - a) (b - a)(c - a) (b - a)(c - a)
aa a

• For right side b = rsample = c


(c - rsample )2
x =1 -
(c - b)(c - a)
since
c c c
2(c - z) 2cz - z2 (c - rsample ) 2
f(z)dz = dz = =
(c - b)(c - a) (c - b)(c - a) (c - b)(c - a)
rsample rsample rsample
© 2008    Winton
8

Sampling Function
b
(b - a)
• Since          f(z)dz
             =                                    (area of left triangle)
(c - a)
a
(b - a)
if   x   =                              use the left side equation to
(c - a)
solve for rsample ; otherwise use the right side
equation

rsample = a + (b - a)(c - a)x for    x= (b - a)/(c - a)


rsample = c - (c - b)(c - a)(1 - x) for    x> (b - a)/(c - a)
© 2008    Winton
9

Graph of Sampling Function:


Triangular Distribution
rsample

•Example: c

–the median corresponds to x = 0.5)


– For a=1, b = 2, c = 4
mean = (a+b+c)/3 = 2.333
mode = 2 b
median =
c - (c - b)(c - a)(0.5) = 4 - 3 = 2.268 a

x
0 1

(b-a)/(c-a)
© 2008    Winton
10

V. Gamma Distribution
• Background: Gamma Function
– One of a large number of functions related to the
exponential function
– Traces from 18 th century work by Euler in which he
was using interpolation methods to define n! for non-
integral values
• dubbed the gamma function by LeGendre in a series of books
published between 1811 and 1826
– Appears naturally in the study of anti-differentiation
• Also studied in the context of differential equations when
calculating LaPlace transforms
• The gamma function is given by
8
G(a) = xa -1 e- x dx (a > 0)
0
© 2008    Winton
11

Gamma Function Definition


•The gamma function is given by
8
G(a) = xa -1 e- x dx (a > 0)
0
• Integrate (by parts) to get G(a) = (a-1)G(a-1)    for a > 1
8
– G(1) = e- x dx = 1
0
– When a is an integer > 1,    G(a) = (a -1)!
– The gamma function is a generalization of the factorial, applying
to all a > 1, not just integers
© 2008    Winton
12

Obtaining the Gamma Distribution

•The gamma distribution is obtained from


the gamma function by specifying the pdf
x
-
f(x) = kxa - 1 e ß for x > 0 for fixed a > 0 and ß > 0
0 otherwise

where the proportionality constant k is


8
chosen so that f(x)dx = 1.
-8
© 2008    Winton
13

Proportionality Constant k
8 8 x 8
-
f(x)dx = 1. = k xa - 1 e ß dx = kßa ta - 1 e- t dt where x = ßt
-8 0 0
G(a)
1 1
k =f(x) is given by
so and xa e
- 1 - x/ß

ßa G(a) ßa G()
a

• a is called shape (or order) parameter


• ß us called the scale parameter
1
1 ß ·x
-
·e
– When a = 1, f(x) =                                  the exponential distribution with mean ß
ß
• In general, E(X) = aß and    s 2 = aß 2
– If the mean and standard deviation can be estimated
then a and ß can also be determined
© 2008    Winton
14

Gamma Function Reflection Formula


8
G(a ) = xa -1 e-x dx (a > 0)
0
• The general relationship G(a) = (a-1)G(a-1)    for a > 1 holds
• It can also be shown that for    0 < a < 1
p
G(a ·)G(1 - a ) =
sin(p a)
– G(.5) = p
• For 0 < a < 1, 1 + a > 1, so G(1+a) = aG(a)
– This gives the reflection formula
p ·a
G(1 - a) = for 0 < a < 1
G(1+ a )sin(p ·a)
Algorithm for Calculating the Natural
© 2008    Winton
15

Logarithm of the Gamma Function


Attributed to Lanczos, C., Journal S.I.A.M. Numerical Analysis ,    ser. B, vol. 1, p. 86 (1964)
and adapted from Numerical Recipes in C by Press, W.H., and B.P. Flannery, S.A.
Teukolsky, W.T. Vetterling (Cambridge University Press, 1988)
FUNCTION    lngamma(z)
/* Use the reflection formula for z < 1    */
IF    z < 1
z      1 - z
RETURN    ln(pz) - (lngamma(1 + z) + ln(sin(pz))
ENDIF
coeff      76.18009173, -86.50532033, 24.01409822, -1.231739516, 0.00120858003, -0.00000536382
/* These values are the (approximate) coefficients for the first 6 terms of an infinite series involved in
an exact formulation for the gamma function credited to Lanczos.    They yield an approximation for the
variable "a" (determined below) which is within | e| < 2 × 10-10 of its true value */
a      1
FOR    i      1    TO    6
a      a + coeff(i)/(i + z - 1)
ENDFOR
RETURN ln(a) - (z + 4.5) + (z - 0.5)ln(z + 4.5)
END
© 2008    Winton
16

Selected Values of G(a)


computed according to the algorithm for ln(G(a))
G(a)
G(.25) ˜ 3.62560991
G(.5) =        ˜ 1.77245385 p
G(.75) ˜ 1.22541670 10
G(1) = 0! = 1
G(1.25) ˜ 0.90640248
p /2
G(1.5) = .5G (.5) =          ˜ 0.88622693 8
G(1.75) ˜ 0.91906253
G(2) = 1! = 1
G(2.25) ˜ 1.13300310
3 p /4
G(2.5) = 1.5G (1.5) =          ˜ 1.32934039 6 x
G(2.75) ˜ 1.60835942
G(3) = 2! = 2 0! 1! 2! 3!
G(3.25) ˜ 2.54925697
4
15 p / 8
G(3.5) = 2.5G (2.5) =          ˜ 3.32335097
G(3.75) ˜ 4.42298841
G(4) = 3! = 6
G(4.25) ˜ 8.28508514 2 x
105 p /16
G(4.5) = 3.5G (3.5) =        ˜ 11.63172840
G(4.75) ˜ 16.58620654 xx
G(5) = 4! = 24 a
G(5.25) ˜ 35.21161185 0
945 p /32
G(5.5) = 4.5G (4.5) =      ˜ 52.34277778 012345
G(5.75) ˜ 78.78448105
G(6) = 5! = 120
© 2008    Winton
17

Graph of Gamma pdf


fixed mean aß = 5 and varying values of a and ß
f(x)
0.6

0.5
a=.5, ß=10
0.4
a=1.5, ß=3.3333
0.3 a=5, ß=1
a=10, ß=.5
0.2

0.1

0 x
0 5 10
© 2008    Winton
18

Corresponding Distribution
Functions and Sampling Functions
F(x)
rsample
10
1

.6
6

.2

2
0
0 10
0
0 .6 .2 1
• The gamma distribution is used to model waiting times or time to complete a task
• It can be shown that if we have exponentially distributed interarrival times with
mean 1/ , the time needed to obtain k changes distributes according to a gamma
distribution with a = k and ß = 1/
Gamma Distribution Behavior
© 2008    Winton
19

x
-
f(x) = kxa - 1 e ß
for x > 0 for fixed a > 0 and ß > 0
0 otherwise
•If
– a < 1 then x a -1 8 as x      0
– a = 1 then the distribution is the exponential distribution
– a > 1 then x a -1 0    as x      0
• The example showed three basic shapes, each of which is described by the
behavior of the derivative f '(x)    (slope function) of f(x)
– f '(x) = k[(a -1)x a -2 e -x/ß + (-1/ß)x a -1 e -x/ß ]

• There are actually 5 cases:


– a < 1 the slope      -8 as x      0    since each term is < 0 and each exponent of x is    < 0
– a = 1 the slope      -1/ß 2 as x      0 in accord with the exponential distribution

since k = 1/ß, term 1 is 0 and term 2 is -1/ß


– a < 2 and a > 1 the slope      +8 as x      0 since the lead term      +8 and term 2 is 0
– a = 2 the slope        +1/ß 2 as x      0 since k = 1/ß a = 1/ß 2

– a > 2 the slope        0    as x      0


• In each case the slope        0    as x      +8
• The gamma distribution is one which is usually sampled by the accept-reject
technique, which means to get k, the value of    G(a) must be computed
© 2008    Winton
20

VI. Erlang Distribution


• Erlang was a Danish telephone engineer who did some of the early work in
queuing theory
• For the Gamma distribution, when a is an integer    i, then the gamma
distribution is called an Erlang distribution of order i
• The Erlang distribution is used to model phenomena having    i    stages, each
with independent, exponentially distributed service times of mean µ
• Rather than model these separately, an Erlang distribution of order i can be
used to model the total service time
– e.g., if an experiment has 3 successive stages each of which takes an average of 5
minutes (exponentially distributed), then the experiment time can be modeled by
taking a = 3 and ß = 5 (to get the overall mean of aß = 15 minutes)
© 2008    Winton
21

VII. Weibull Distribution


8
• For the gamma distribution the idea was to choose k so that k xa - 1 e- x/ß dx
is equal to 1 and then choose f(x) = kx a-1 e -x/ß 0

• A major difficulty with this pdf is that it is not integrable in closed


form; however, it is close to being so
• The idea is to render the part under the integral to be in the form e z dz
8
so that the function will be integrable; i.e., for k e- ()x/ßdx? xa - 1
0

we need to determine the ? value so that for z = -(x/ß) ? ,    dz = xa-1 dx


• If    z = -(x/ß) a then dz = -(a/ß)(x/ß) a -1 dx and then
- ßa 8 - ()x/ß a - a ()x/ß a -1 - ßa () a
8 ßa a
k · e dx = k e- x/ß =k = 1when k=
a ß a 0 a ßa
0
© 2008    Winton
22

Weibull pdf
• The choice of k=a/ß a is the basis for the pdf
a
a - 1 - x -d
a-x d ß
f(x) = e for x = d
ß ß
0 otherwise
– the effect of    d is to displace the distribution    d
along the horizontal axis, so it is often taken to
be 0
• With a little work, it can be shown that
– E(X) = d + ßG(1 + 1/a)    and
– VAR(X) = ß 2 (G(1 + 2/a) - G 2 (1 + 1/a))
© 2008    Winton
23

Sampling
•Since
rsample rsample
e- ()()x (- d) /ß
a a
x= f(z)dz = - = 1- e- (rsample - d)/ß
d d
the sample function can be solved for rsample for given
values of a, ß, d
• The Weibull distribution is often used to model time until
failure (for example, light bulbs may have significant early
failure and some have significant long term until failure)
– When a = 1, ß = 1/ , d = 0 then the Weibull distribution is the
exponential distribution
© 2008    Winton
24

Graph
Weibull pdf for fixed ß = 1 and varying values of a
f(x)
4
a=10, ß=1

a=.5, ß=1
2
a=5, ß=1

1 a=1.5, ß=3.3333

0 x
01234

You might also like