Matlab: Simulation Modeling with Continuous Random Variables
Chapter 6: Probability Models of Derived Ran- dom Variables
Introduction
In many situations, we observe one or more random variables and use their values to compute a new random variable. More formally, we have the following situations.
• We perform an experiment and observe a sample value of random variable X. Based on our knowledge of the experiment, we have a probability model for X embodied in the PMF PX(x) or the PDF fX(x). After performing the experiment, we calculate a sample value of the random variable W = g(X).
• We perform an experiment and observe a sample value of two random variables X and Y . Based on our knowledge of the experiment, we have a probability model for X and Y embodied in a joint PMF PX,Y (x,y) or a joint PDF fX,Y (x,y). After performing the experiment, we calculate a sample value of the random variable W = g(X,Y ).
In both cases, the mathematical problem is to determine the properties of W . Previous chapters addressed aspects of this problem. For example, In Chapter 4, on continuous ran- dom variables, a formula was given for E[W ] given fX(x) and g(X); however, in this chapter, the focus is on the probability model of W. Similarly, although in Chapter 5 E[g(X,Y )] was examined, the focus in this chapter is on finding the PMF or PDF of W = g(X,Y ). In summary, in this chapter, the focus is on some methods for deriving the distribution (PMF, CDF, or PDF) of a function of one or two random variables.
6.1 PMF of a Function of Two Discrete Random Variables
When X and Y are discrete random variables, SW , the range of W , is a countable set corresponding to all possible values of g(X,Y ). Therefore, W is a discrete random variable and has a PMF PW (w). Note that {W = w} is equivalent to to the event {g(X,Y ) = w}. Therefore, we can obtain PW (w) by adding all the values of PX,Y (x,y) corresponding to the (x,y) pairs for which g(x,y) = w.
Theorem 6.1 For discrete random variables X and Y , the derived random variable W = g(X,Y ) has PMF
PW (w) = ∑
(x,y):g(x,y)=w
PX,Y (x,y).
Example 1 Repeating Example 12 from Chapter 5, a firm produces two kinds of advertisement flyers for its clients, which it places on its client’s website. One kind contains only text and costs $30 per page. The other kind contains a mixture of text and pictures and costs $90 per page. Clients can only purchase one type or the other. The size of the flyer can be
64
1, 2, or 3 webpages long. Let the random variable L represent the length of the flyer; thus SL = {1, 2, 3}. Let the random variable C represent the cost of the flyer; thus SC = {30, 90}. After observing many requests for flyers, the firm derives the following probability model:
PL,C(l,c) c = $30/page c = $90/page l = 1 page 0.15 0.25 l = 2 pages 0.05 0.20 l = 3 pages 0.10 0.25
Let W = g(L,C) = LC be the total cost of the flyer. Find the range SW of the random variable W and the PMF PW (w).
6.2 Functions Yielding Continuous Random Variables
Suppose W = g(X). The objective in this section is to determine fW (w), the PDF of W. In Chapter 3, we saw that determining a derived PMF of a discrete random variable was relatively straightforward in the sense that the new PMF was derived directly from the original one.
For continuous random variables, the process can be somewhat more complicated. The process relies on the following two-step procedure, which is straightforward in the case of linear functions but can be more complex for other functions.
1. Find the CDF FW (w) = P [W ≤ w]. 2. Compute the PDF by calculating the derivative fW (w) = dFW (w)/dw.
Example 2 (page 221) In Example 1 of Chapter 4, we spun a pointer around a wheel that was one meter in circumference, and the random variable X, the location of the pointer, was uniformly dis- tributed on the 1-meter circumference of the circle. Suppose we let W represent the location of the pointer, in centimeters, around the 1-meter circumference of the circle. Therefore, W = g(X) = 100X. Derive fW (w).
Solution. Step one of the procedure requires finding the CDF of W . By definition, FW (w) = P [W ≤ w]; substituting for W = 100X results in P [100X ≤ w] = P [X ≤ w/100] = FX(w/100). Therefore, FW (w) = FX(w/100). Now all we need to do is determine the CDF of X and substitute the argument w/100 for x. From Example 1 of Chapter 4, the CDF of X is
FX(x) =
0 x < 0, x 0 ≤ x < 1, 1 x ≥ 1.
65
Substituting w/100 for x results in
FW (w) = FX(w/100) =
0 w/100 < 0, w/100 0 ≤ w/100 < 1, 1 w/100 ≥ 1.
Step two of the procedure calls for computing the PDF fW (w) by taking the derivative of the CDF FW (w), which, in this example, is equal to the CDF FX(w/100). Inspection of the CDF FX(w/100) indicates that the derivative is zero everywhere except in the range 0 ≤ w/100 < 1, or equivalently, in the range 0 ≤ w < 100. Therefore,
fW (w) = dFW (w)
dw = dFX(w/100)
dx
dx
dw = (1)
1
100 =
{ 1/100 0 ≤ w < 100, 0 otherwise,
because dFX(x) dx
= dFX(w/100)
dx = fX(w/100) = 1 for this example. W turns out, not surpris-
ingly, to be a uniform (0, 100) random variable. We can generalize this two-step procedure to derive the CDF and PDF for any scale change and any continuous random variable, as indicated in the following theorem.
Theorem 6.2 If W = aX, where a > 0, then W has the following CDF and PDF:
FW (w) = FX(w/a), fW (w) = 1
a fX(w/a).
To compute fX(w/a), one substitutes w/a for x in the formula for fX(x). In the case of our previous example, where X was a uniform (0,1) random variable with fX(x) = 1, there was no variable x in the PDF formula. Therefore, fW (w) would simply compute to
1 a
or 1 100
, which is the result we obtained. Essentially, Theorem 6.2 states that multiplying a random variable by a positive constant stretches the original PDF (which occurs when a > 1) or shrinks the original PDF (which occurs when a < 1).
As implied in the solution of our previous example, the solution for fW (w) provided in Theorem 6.2 can be shown to be a result of the chain rule. First note that for W = aX,
FW (w) = FX(w/a); therefore, fW (w) = dFW (w)
dw = dFX(w/a)
dw .
Applying the chain rule results in
dFX(w/a)
dw = dFX(w/a)
dx
dx
dw = fX(w/a)
1
a ,
which is the statement of Theorem 6.2.
Theorem 6.2 can be stated in a different form, where it can be applied to any func- tion g(X) that is a strictly monotone (increasing or decreasing), differentiable (and thus continuous) function of X.
Theorem 6.21 Let X be a continuous random variable having probability density function fX(x). Suppose that g(X) is a strictly monotone (increasing or decreasing), differentiable
1This form of Theorem 6.2 is not in the text.
66
(and thus continuous) function of X. Then the random variable W = g(X) has a PDF given by
fW (w) =
{ fX[g
−1(w)] ∣∣∣ d dw g−1(w)
∣∣∣ w = g(x) for some x, 0 w 6= g(x) for all x,
where g−1(w) is defined as being equal to that value of x such that g(x) = w. Thus, if W = 100X, x = g−1(w) = w/100.
Theorem 6.2 can be used to show that, for the families of continuous random variables discussed in Chapter 4, multiplying the random variable by a constant produces a new family member with the following transformed parameters:
Theorem 6.3 If W = aX, where a > 0, then:
(a) If X is uniform (b,c), then W is uniform (ab,ac).
(b) If X is exponential (λ), then W is exponential (λ/a).
(c) If X is Erlang (n,λ), then W is Erlang (n,λ/a).
(d) If X is Gaussian (µ,σ), then W is Gaussian (aµ,aσ).
Theorem 6.4 If W = X + b, then
FW (w) = FX(w − b), fW (w) = fX(w − b).
This theorem states that adding a constant to a random varible simply shifts the CDF and the PDF by that constant.
Example 3 (page 222, modified) Let X have the triangular PDF
fX(x) =
{ 2x 0 ≤ x ≤ 1, 0 otherwise,
and let W = aX + b.
(a) Find the PDF of W when a = 1/2 and b = 0 (i.e., W = X/2).
(b) Find the PDF of W when a = 1 and b = 3 (i.e., W = X + 3).
(c) Plot the PDFs of W when a = 1,b = 0, a = 1/2,b = 0, and a = 1,b = 3.
Example 4 Let X be a uniform (0, 1) random variable, and define W = g(X) = Xn. Thus 0 ≤ w ≤ 1. Is W a strictly monotone function of X? Find fW (w).
67
When W = g(X) is not a strictly monotone function of X, then g(X) may transform more than one value of X to the same value of W. Unlike with linear transformations, in such cases there are no cookbook procedures for deriving the PDF of W, as illustrated in the next example.
Example 5 (page 223) Suppose X is uniformly distributed over [−1, 3] and W = X2. Find the CDF FW (w) and the PDF fW (w).
We often use computer simulation as a method for investigating various phenomena that have random components. In building such simulations, we often need to generate values for particular random variables, such as exponential random variables. Although a number of methods for generating random variables exist, all of these methods are based on the availability of random numbers that are uniformly distributed between zero and one.
We will not discuss how to generate numbers from a uniform (0, 1) distribution—a number of methods for doing this exist and are the basis for the random number generators that exist in computers. Here, we will discuss one theorem that enables the generation of values of certain random variables to be generated, particularly those random variables with a CDF that is an easily invertible function (i.e., an inverse can be easily computed).
Theorem 6.5 Let U be a uniform (0, 1) random variable and let F(x) denote a cumulative distribution function with an inverse F−1(u) defined for 0 < u < 1. The random variable X = F−1(U) has CDF FX(x) = F(x).
To understand this theorem, first consider the goal: we want to generate a random variable X that has CDF FX(x). We define the random variable X = F
−1(U). This means that first U is selected (i.e., a value from a uniform (0, 1) distribution is generated), and then a corresponding value of X = x is obtained, based on the relationship F(x) = u, such that the probability that X is less than or equal to this value of x is equal to that value of U. That is,
P [X ≤ x] = P [F−1(U) ≤ x] = P [U ≤ F (x)] = u. Because U is uniformly (0, 1) distributed and 0 ≤ u ≤ 1, P[U ≤ u] is simply u. Therefore, P [U ≤ F(x)] = F(x), and the random variable X has CDF FX(x) = F(x). However, for this to work, F−1(u) must be a nondecreasing function, which can be verified. Also, the function FX(u) must have an inverse for 0 < u < 1.
Example 6 (page 225) Let U be the uniform (0, 1) random variable and let X = g(U). Derive g(U) such that X is the exponential (1) random variable. That is, use Theorem 6.5 to generate a random variable that has an exponential distribution with parameter λ = 1.
Solution. The CDF of X is
FX(x) =
{ 0 x < 0, 1 −e−λx x ≥ 0.
68
Essentially, the method calls for selecting a value of u from the uniform (0, 1) distribution, and then finding a value of x such that 1 −e−λx = u. Thus u = 1 −e−λx. By inverting this expression, we obtain
1 −u = e−λx; ln(1 −u) = −λx; x = −ln(1 −u) λ
= F−1(U).
For λ = 1, X = g(U) = −ln(1 −U).
6.4 Continuous Functions of Two Continuous Random Variables
When X and Y are continuous random variables and g(x,y) is a continuous function, W = g(X,Y ) is a continuous random variable. To find the PDF, fW (w), it is usually helpful to first find the CDF FW (w) and then calculate the derivative. Viewing {W ≤ w} as an event A, Theorem 5.7 can be applied, as the following theorem implies.
Theorem 6.6 For continuous random variables X and Y , the CDF of W = g(X,Y ) is
FW (w) = P [W ≤ w] = ∫ ∫
g(x,y) ≤ w
fX,Y (x,y) dxdy.
Theorem 6.6 is analogous to the approach that was used in Section 6.2 for functions W = g(X). There, the function g(X) was used to translate the event {W ≤ w} into an event {g(X) ≤ w} that was a subset of the X-axis. FW (w) was then calculated by integrating fX(x) over that subset.
In Theorem 6.6, the event {g(X,Y ) ≤ w} is translated into a region of the X,Y plane. Integrating the joint PDF fX,Y (x,y) over that region will yield the CDF FW (w). Once FW (w) is obtained, it is generally straightforward to calculate the derivative fW (w) = dFW (w)/dw.
Unfortunately, for most functions g(x,y), performing the integration as specified in The- orem 6.6 to find FW (w) can be a tedious process. However, there do exist convenient tech- niques for finding fW (w) for certain functions that arise in many applications. The most important function, g(X,Y ) = X +Y is covered in Section 6.5 and Chapter 9. The following theorem addresses the case where W is the maximum of two random variables. Note that in this situation, the event {W ≤ w} = {X ≤ w}∩{Y ≤ w}. Theorem 6.7 For continuous random variables X and Y , the CDF of W = max(X,Y ) is
FW (w) = FX,Y (w,w) = ∫ w −∞
∫ w −∞
fX,Y (x,y) dxdy.
Example 7 (page 230) The random variables X and Y have joint PDF
fX,Y (x,y) =
{ 1/15 0 ≤ x ≤ 5, 0 ≤ y ≤ 3, 0 otherwise.
Find the PDF of W = max(X,Y ).
69
6.5 The PDF of the Sum of Two Random Variables
Consider the sum W = X + Y of two continuous random variables. The PDF of W can be found by using the two-step procedure that was introduced in Section 6.2 for the case of a single continuous random variable: (1) first, we find the CDF FW (w) by integrating the joint PDF fX,Y (x,y) over the region X +Y ≤ w; (2) next, we take the derivative of the CDF to find the PDF. The result of this process is summarized in the next theorem.
Theorem 6.8 The PDF of W = X + Y is
fW (w) = ∫ ∞ −∞
fX,Y (x,w −x) dx = ∫ ∞ −∞
fX,Y (w −y,y) dy.
A very important special case of Theorem 6.8 occurs when X and Y are independent, in which case the joint PDF of X and Y can be written as the product of the marginals: fX,Y (x,y) = fX(x)fY (y).
Theorem 6.9 When X and Y are independent, the PDF of W = X + Y is
fW (w) = ∫ ∞ −∞
fX(w −y)fY (y) dy = ∫ ∞ −∞
fX(x)fY (w −x) dx.
This result can be obtained as follows (not shown in text). First, we obtain the CDF of W by using the first step of the two-step procedure:
FW (w) = P[X + Y ≤ w] = ∫ ∫
x+y≤w fX(x)fY (y) dxdy
= ∫ ∞ −∞
(∫ w−y −∞
fX(x) dx ) fY (y) dy =
∫ ∞ −∞
FX(w −y)fY (y) dy.
By differentiating the CDF of W , we obtain the PDF fW (w):
fW (w) = dFW (w)
dw =
d
dw
∫ ∞ −∞
FX(w −y)fY (y) dy
= ∫ ∞ −∞
d
dw FX(w −y)fY (y) dy =
∫ ∞ −∞
fX(w −y)fY (y) dy.
Making the substitution y = w −x gives us the other result in Theorem 6.9. Theorem 6.9 combines the two single variable (i.e., univariate) probability functions,
fX(·) and fY (·), in order to produce a third function, fW (·). This combination is called a convolution. Sometimes the notation fW (w) = fX(x)∗fY (y) is used to denote a convolution.
When X and Y are independent discrete random variables, the PMF of W = X + Y is the following discrete convolution of the two PMFs:
PW (w) = ∞∑
k=−∞ PX(k)PY (w −k).
70
Example 8 Let X and Y be two independent variables with PDFs:
fX(x) =
{ e−x x > 0, 0 otherwise.
fY (y) =
{ e−y y > 0, 0 otherwise.
and let W = X + Y . Determine fW (w) using the convolution integral.
71