392
1 Sample Space and Probability Contents 1.1. Sets ........................... p. 3 1.2. Probabilistic Models .................... p. 6 1.3. Conditional Probability ................. p. 16 1.4. Total Probability Theorem and Bayes’ Rule ........ p. 25 1.5. Independence ...................... p. 31 1.6. Counting ....................... p. 41 1.7. Summary and Discussion ................ p. 48 1

1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Embed Size (px)

Citation preview

Page 1: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

1

Sample Space and

Probability

Contents

1.1. Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . p. 31.2. Probabilistic Models . . . . . . . . . . . . . . . . . . . . p. 61.3. Conditional Probability . . . . . . . . . . . . . . . . . p. 161.4. Total Probability Theorem and Bayes’ Rule . . . . . . . . p. 251.5. Independence . . . . . . . . . . . . . . . . . . . . . . p. 311.6. Counting . . . . . . . . . . . . . . . . . . . . . . . p. 411.7. Summary and Discussion . . . . . . . . . . . . . . . . p. 48

1

Page 2: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

2 Sample Space and Probability Chap. 1

“Probability” is a very useful concept, but can be interpreted in a number ofways. As an illustration, consider the following.

A patient is admitted to the hospital and a potentially life-saving drug isadministered. The following dialog takes place between the nurse and aconcerned relative.

RELATIVE: Nurse, what is the probability that the drug will work?NURSE: I hope it works, we’ll know tomorrow.RELATIVE: Yes, but what is the probability that it will?NURSE: Each case is different, we have to wait.RELATIVE: But let’s see, out of a hundred patients that are treated undersimilar conditions, how many times would you expect it to work?NURSE (somewhat annoyed): I told you, every person is different, for someit works, for some it doesn’t.RELATIVE (insisting): Then tell me, if you had to bet whether it will workor not, which side of the bet would you take?NURSE (cheering up for a moment): I’d bet it will work.RELATIVE (somewhat relieved): OK, now, would you be willing to losetwo dollars if it doesn’t work, and gain one dollar if it does?NURSE (exasperated): What a sick thought! You are wasting my time!

In this conversation, the relative attempts to use the concept of probability todiscuss an uncertain situation. The nurse’s initial response indicates that themeaning of “probability” is not uniformly shared or understood, and the relativetries to make it more concrete. The first approach is to define probability interms of frequency of occurrence, as a percentage of successes in a moderatelylarge number of similar situations. Such an interpretation is often natural. Forexample, when we say that a perfectly manufactured coin lands on heads “withprobability 50%,” we typically mean “roughly half of the time.” But the nursemay not be entirely wrong in refusing to discuss in such terms. What if thiswas an experimental drug that was administered for the very first time in thishospital or in the nurse’s experience?

While there are many situations involving uncertainty in which the fre-quency interpretation is appropriate, there are other situations in which it isnot. Consider, for example, a scholar who asserts that the Iliad and the Odysseywere composed by the same person, with probability 90%. Such an assertionconveys some information, but not in terms of frequencies, since the subject isa one-time event. Rather, it is an expression of the scholar’s subjective be-lief. One might think that subjective beliefs are not interesting, at least from amathematical or scientific point of view. On the other hand, people often haveto make choices in the presence of uncertainty, and a systematic way of makinguse of their beliefs is a prerequisite for successful, or at least consistent, decision

Page 3: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.1 Sets 3

making.In fact, the choices and actions of a rational person, can reveal a lot about

the inner-held subjective probabilities, even if the person does not make conscioususe of probabilistic reasoning. Indeed, the last part of the earlier dialog was anattempt to infer the nurse’s beliefs in an indirect manner. Since the nurse waswilling to accept a one-for-one bet that the drug would work, we may inferthat the probability of success was judged to be at least 50%. And had thenurse accepted the last proposed bet (two-for-one), that would have indicated asuccess probability of at least 2/3.

Rather than dwelling further into philosophical issues about the appropri-ateness of probabilistic reasoning, we will simply take it as a given that the theoryof probability is useful in a broad variety of contexts, including some where theassumed probabilities only reflect subjective beliefs. There is a large body ofsuccessful applications in science, engineering, medicine, management, etc., andon the basis of this empirical evidence, probability theory is an extremely usefultool.

Our main objective in this book is to develop the art of describing un-certainty in terms of probabilistic models, as well as the skill of probabilisticreasoning. The first step, which is the subject of this chapter, is to describethe generic structure of such models, and their basic properties. The models weconsider assign probabilities to collections (sets) of possible outcomes. For thisreason, we must begin with a short review of set theory.

1.1 SETS

Probability makes extensive use of set operations, so let us introduce at theoutset the relevant notation and terminology.

A set is a collection of objects, which are the elements of the set. If S isa set and x is an element of S, we write x ∈ S. If x is not an element of S, wewrite x /∈ S. A set can have no elements, in which case it is called the emptyset, denoted by Ø.

Sets can be specified in a variety of ways. If S contains a finite number ofelements, say x1, x2, . . . , xn, we write it as a list of the elements, in braces:

S = x1, x2, . . . , xn.

For example, the set of possible outcomes of a die roll is 1, 2,3, 4, 5,6, and theset of possible outcomes of a coin toss is H, T, where H stands for “heads”and T stands for “tails.”

If S contains infinitely many elements x1, x2, . . ., which can be enumeratedin a list (so that there are as many elements as there are positive integers) wewrite

S = x1, x2, . . .,

Page 4: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

4 Sample Space and Probability Chap. 1

and we say that S is countably infinite. For example, the set of even integerscan be written as 0,2,−2, 4,−4, . . ., and is countably infinite.

Alternatively, we can consider the set of all x that have a certain propertyP , and denote it by

x |x satisfies P.(The symbol “|” is to be read as “such that.”) For example the set of evenintegers can be written as k | k/2 is integer. Similarly, the set of all scalars xin the interval [0, 1] can be written as x | 0 ≤ x ≤ 1. Note that the elements xof the latter set take a continuous range of values, and cannot be written downin a list (a proof is sketched in the end-of-chapter problems); such a set is saidto be uncountable.

If every element of a set S is also an element of a set T , we say that Sis a subset of T , and we write S ⊂ T or T ⊃ S. If S ⊂ T and T ⊂ S, thetwo sets are equal, and we write S = T . It is also expedient to introduce auniversal set, denoted by Ω, which contains all objects that could conceivablybe of interest in a particular context. Having specified the context in terms of auniversal set Ω, we only consider sets S that are subsets of Ω.

Set Operations

The complement of a set S, with respect to the universe Ω, is the set x ∈Ω | x /∈ S of all elements of Ω that do not belong to S, and is denoted by Sc.Note that Ωc = Ø.

The union of two sets S and T is the set of all elements that belong to Sor T (or both), and is denoted by S ∪T . The intersection of two sets S and Tis the set of all elements that belong to both S and T , and is denoted by S ∩ T .Thus,

S ∪ T = x | x ∈ S or x ∈ T,S ∩ T = x | x ∈ S and x ∈ T.

In some cases, we will have to consider the union or the intersection of several,even infinitely many sets, defined in the obvious way. For example, if for everypositive integer n, we are given a set Sn, then

∞⋃

n=1

Sn = S1 ∪ S2 ∪ · · · = x | x ∈ Sn for some n,

and ∞⋂

n=1

Sn = S1 ∩ S2 ∩ · · · = x | x ∈ Sn for all n.

Two sets are said to be disjoint if their intersection is empty. More generally,several sets are said to be disjoint if no two of them have a common element. Acollection of sets is said to be a partition of a set S if the sets in the collectionare disjoint and their union is S.

Page 5: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.1 Sets 5

If x and y are two objects, we use (x, y) to denote the ordered pair of xand y. The set of scalars (real numbers) is denoted by <; the set of pairs (ortriplets) of scalars, i.e., the two-dimensional plane (or three-dimensional space,respectively) is denoted by <2 (or <3, respectively).

Sets and the associated operations are easy to visualize in terms of Venndiagrams, as illustrated in Fig. 1.1.

S

T

Ω

T

Ω ΩS S

T

(a) (b)

S

T

Ω

(c)

S

T

Ω

(d) (e)

U S

(f)

U

Figure 1.1: Examples of Venn diagrams. (a) The shaded region is S ∩ T . (b)The shaded region is S ∪ T . (c) The shaded region is S ∩ T c. (d) Here, T ⊂ S.The shaded region is the complement of S. (e) The sets S, T , and U are disjoint.(f) The sets S, T , and U form a partition of the set Ω.

The Algebra of Sets

Set operations have several properties, which are elementary consequences of thedefinitions. Some examples are:

S ∪ T = T ∪ S, S ∪ (T ∪ U) = (S ∪ T ) ∪ U,S ∩ (T ∪ U ) = (S ∩ T ) ∪ (S ∩ U ), S ∪ (T ∩ U) = (S ∪ T ) ∩ (S ∪ U),

(Sc)c = S, S ∩ Sc = Ø,S ∪ Ω = Ω, S ∩Ω = S.

Two particularly useful properties are given by de Morgan’s laws whichstate that (

n

Sn

)c

=⋂

n

Scn,

(⋂

n

Sn

)c

=⋃

n

Scn.

To establish the first law, suppose that x ∈ (∪nSn)c. Then, x /∈ ∪nSn, whichimplies that for every n, we have x /∈ Sn. Thus, x belongs to the complement

Page 6: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

6 Sample Space and Probability Chap. 1

of every Sn, and xn ∈ ∩nScn. This shows that (∪nSn)c ⊂ ∩nSc

n. The converseinclusion is established by reversing the above argument, and the first law follows.The argument for the second law is similar.

1.2 PROBABILISTIC MODELS

A probabilistic model is a mathematical description of an uncertain situation.It must be in accordance with a fundamental framework that we discuss in thissection. Its two main ingredients are listed below and are visualized in Fig. 1.2.

Elements of a Probabilistic Model

• The sample space Ω, which is the set of all possible outcomes of anexperiment.

• The probability law, which assigns to a set A of possible outcomes(also called an event) a nonnegative number P(A) (called the proba-bility of A) that encodes our knowledge or belief about the collective“likelihood” of the elements of A. The probability law must satisfycertain properties to be introduced shortly.

Experiment

Sample Space Ω(Set of Outcomes)

Event A

Event B

A B Events

P(A)

P(B)

ProbabilityLaw

Figure 1.2: The main ingredients of a probabilistic model.

Sample Spaces and Events

Every probabilistic model involves an underlying process, called the experi-ment, that will produce exactly one out of several possible outcomes. The setof all possible outcomes is called the sample space of the experiment, and isdenoted by Ω. A subset of the sample space, that is, a collection of possible

Page 7: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.2 Probabilistic Models 7

outcomes, is called an event.† There is no restriction on what constitutes anexperiment. For example, it could be a single toss of a coin, or three tosses,or an infinite sequence of tosses. However, it is important to note that in ourformulation of a probabilistic model, there is only one experiment. So, threetosses of a coin constitute a single experiment, rather than three experiments.

The sample space of an experiment may consist of a finite or an infinitenumber of possible outcomes. Finite sample spaces are conceptually and math-ematically simpler. Still, sample spaces with an infinite number of elements arequite common. For an example, consider throwing a dart on a square target andviewing the point of impact as the outcome.

Choosing an Appropriate Sample Space

Regardless of their number, different elements of the sample space should bedistinct and mutually exclusive so that when the experiment is carried out,there is a unique outcome. For example, the sample space associated with theroll of a die cannot contain “1 or 3” as a possible outcome and also “1 or 4” asanother possible outcome. When the roll is a 1, the outcome of the experimentwould not be unique.

A given physical situation may be modeled in several different ways, de-pending on the kind of questions that we are interested in. Generally, the samplespace chosen for a probabilistic model must be collectively exhaustive, in thesense that no matter what happens in the experiment, we always obtain an out-come that has been included in the sample space. In addition, the sample spaceshould have enough detail to distinguish between all outcomes of interest to themodeler, while avoiding irrelevant details.

Example 1.1. Consider two alternative games, both involving ten successive cointosses:

Game 1: We receive $1 each time a head comes up.

Game 2: We receive $1 for every coin toss, up to and including the first timea head comes up. Then, we receive $2 for every coin toss, up to the secondtime a head comes up. More generally, the dollar amount per toss is doubledeach time a head comes up.

† Any collection of possible outcomes, including the entire sample space Ω andits complement, the empty set Ø, may qualify as an event. Strictly speaking, however,some sets have to be excluded. In particular, when dealing with probabilistic modelsinvolving an uncountably infinite sample space, there are certain unusual subsets forwhich one cannot associate meaningful probabilities. This is an intricate technical issue,involving the mathematics of measure theory. Fortunately, such pathological subsetsdo not arise in the problems considered in this text or in practice, and the issue can besafely ignored.

Page 8: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

8 Sample Space and Probability Chap. 1

In game 1, it is only the total number of heads in the ten-toss sequence that mat-ters, while in game 2, the order of heads and tails is also important. Thus, ina probabilistic model for game 1, we can work with a sample space consisting ofeleven possible outcomes, namely, 0, 1, . . . , 10. In game 2, a finer grain descriptionof the experiment is called for, and it is more appropriate to let the sample spaceconsist of every possible ten-long sequence of heads and tails.

Sequential Models

Many experiments have an inherently sequential character, such as for exampletossing a coin three times, or observing the value of a stock on five successivedays, or receiving eight successive digits at a communication receiver. It is thenoften useful to describe the experiment and the associated sample space by meansof a tree-based sequential description, as in Fig. 1.3.

11 2

2

3

3

4

4

Sequential TreeDescription

Sample SpacePair of Rolls

1st Roll

2nd Roll

1, 11, 21, 31, 4

1

2

3

4

Root Leaves

Figure 1.3: Two equivalent descriptions of the sample space of an experimentinvolving two rolls of a 4-sided die. The possible outcomes are all the ordered pairsof the form (i, j), where i is the result of the first roll, and j is the result of thesecond. These outcomes can be arranged in a 2-dimensional grid as in the figureon the left, or they can be described by the tree on the right, which reflects thesequential character of the experiment. Here, each possible outcome correspondsto a leaf of the tree and is associated with the unique path from the root to thatleaf. The shaded area on the left is the event (1, 4), (2, 4), (3, 4), (4, 4) that theresult of the second roll is 4. That same event can be described as a set of leaves,as shown on the right. Note also that every node of the tree can be identified withan event, namely, the set of all leaves downstream from that node. For example,the node labeled by a 1 can be identified with the event (1, 1), (1, 2), (1, 3), (1, 4)that the result of the first roll is 1.

Probability Laws

Suppose we have settled on the sample space Ω associated with an experiment.

Page 9: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.2 Probabilistic Models 9

Then, to complete the probabilistic model, we must introduce a probabilitylaw. Intuitively, this specifies the “likelihood” of any outcome, or of any set ofpossible outcomes (an event, as we have called it earlier). More precisely, theprobability law assigns to every event A, a number P(A), called the probabilityof A, satisfying the following axioms.

Probability Axioms

1. (Nonnegativity) P(A) ≥ 0, for every event A.

2. (Additivity) If A and B are two disjoint events, then the probabilityof their union satisfies

P(A ∪ B) = P(A) + P(B).

Furthermore, if the sample space has an infinite number of elementsand A1,A2, . . . is a sequence of disjoint events, then the probability oftheir union satisfies

P(A1 ∪ A2 ∪ · · ·) = P(A1) + P(A2) + · · ·

3. (Normalization) The probability of the entire sample space Ω isequal to 1, that is, P(Ω) = 1.

In order to visualize a probability law, consider a unit of mass which isto be “spread” over the sample space. Then, P(A) is simply the total massthat was assigned collectively to the elements of A. In terms of this analogy, theadditivity axiom becomes quite intuitive: the total mass in a sequence of disjointevents is the sum of their individual masses.

A more concrete interpretation of probabilities is in terms of relative fre-quencies: a statement such as P(A) = 2/3 often represents a belief that event Awill materialize in about two thirds out of a large number of repetitions of theexperiment. Such an interpretation, though not always appropriate, can some-times facilitate our intuitive understanding. It will be revisited in Chapter 7, inour study of limit theorems.

There are many natural properties of a probability law which have not beenincluded in the above axioms for the simple reason that they can be derivedfrom them. For example, note that the normalization and additivity axiomsimply that

1 = P(Ω) = P(Ω ∪Ø) = P(Ω) + P(Ø) = 1 + P(Ø),

and this shows that the probability of the empty event is 0:

P(Ø) = 0.

Page 10: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

10 Sample Space and Probability Chap. 1

As another example, consider three disjoint events A1, A2, and A3. We can usethe additivity axiom for two disjoint events repeatedly, to obtain

P(A1 ∪A2 ∪A3) = P(A1 ∪ (A2 ∪ A2)

)

= P(A1) + P(A2 ∪A3)

= P(A1) + P(A2) + P(A3).

Proceeding similarly, we obtain that the probability of the union of finitely manydisjoint events is always equal to the sum of the probabilities of these events.More such properties will be considered shortly.

Discrete Models

Here is an illustration of how to construct a probability law starting from somecommon sense assumptions about a model.

Example 1.2. Coin tosses. Consider an experiment involving a single cointoss. There are two possible outcomes, heads (H) and tails (T ). The sample spaceis Ω = H,T , and the events are

H, T, H, T, Ø.

If the coin is fair, i.e., if we believe that heads and tails are “equally likely,” weshould assign equal probabilities to the two possible outcomes and specify thatP

(H

)= P

(T

)= 0.5. The additivity axiom implies that

P(H,T

)= P

(H

)+ P

(T

)= 1,

which is consistent with the normalization axiom. Thus, the probability law is givenby

P(H, T

)= 1, P

(H

)= 0.5, P

(T

)= 0.5, P(Ø) = 0,

and satisfies all three axioms.Consider another experiment involving three coin tosses. The outcome will

now be a 3-long string of heads or tails. The sample space is

Ω = HHH, HHT, HTH, HTT, THH, THT, TTH, TTT .

We assume that each possible outcome has the same probability of 1/8. Let usconstruct a probability law that satisfies the three axioms. Consider, as an example,the event

A = exactly 2 heads occur = HHT, HTH, THH.

Page 11: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.2 Probabilistic Models 11

Using additivity, the probability of A is the sum of the probabilities of its elements:

P(HHT, HTH, THH

)= P

(HHT

)+ P

(HTH

)+ P

(THH

)

=1

8+

1

8+

1

8

=3

8.

Similarly, the probability of any event is equal to 1/8 times the number of possibleoutcomes contained in the event. This defines a probability law that satisfies thethree axioms.

By using the additivity axiom and by generalizing the reasoning in thepreceding example, we reach the following conclusion.

Discrete Probability Law

If the sample space consists of a finite number of possible outcomes, then theprobability law is specified by the probabilities of the events that consist ofa single element. In particular, the probability of any event s1, s2, . . . , snis the sum of the probabilities of its elements:

P(s1, s2, . . . , sn

)= P

(s1

)+ P

(s2

)+ · · ·+ P

(sn

).

In the special case where the probabilities P(s1), . . . ,P(sn

)are all the

same (by necessity equal to 1/n, in view of the normalization axiom), we obtainthe following.

Discrete Uniform Probability Law

If the sample space consists of n possible outcomes which are equally likely(i.e., all single-element events have the same probability), then the proba-bility of any event A is given by

P(A) =Number of elements of A

n.

Let us provide a few more examples of sample spaces and probability laws.

Example 1.3. Dice. Consider the experiment of rolling a pair of 4-sided dice (cf.Fig. 1.4). We assume the dice are fair, and we interpret this assumption to mean

Page 12: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

12 Sample Space and Probability Chap. 1

that each of the sixteen possible outcomes [ordered pairs (i, j), with i, j = 1, 2, 3, 4],has the same probability of 1/16. To calculate the probability of an event, wemust count the number of elements of event and divide by 16 (the total number ofpossible outcomes). Here are some event probabilities calculated in this way:

P(the sum of the rolls is even

)= 8/16 = 1/2,

P(the sum of the rolls is odd

)= 8/16 = 1/2,

P(the first roll is equal to the second

)= 4/16 = 1/4,

P(the first roll is larger than the second

)= 6/16 = 3/8,

P(at least one roll is equal to 4

)= 7/16.

11 2

2

3

3

4

4

Sample SpacePair of Rolls

1st Roll

2nd Roll

Event the first roll is equal to the second

Probability = 4/16

Event at least one roll is a 4

Probability = 7/16

Figure 1.4: Various events in the experiment of rolling a pair of 4-sided dice,and their probabilities, calculated according to the discrete uniform law.

Continuous Models

Probabilistic models with continuous sample spaces differ from their discretecounterparts in that the probabilities of the single-element events may not besufficient to characterize the probability law. This is illustrated in the followingexamples, which also illustrate how to generalize the uniform probability law tothe case of a continuous sample space.

Page 13: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.2 Probabilistic Models 13

Example 1.4. A wheel of fortune is continuously calibrated from 0 to 1, so thepossible outcomes of an experiment consisting of a single spin are the numbers inthe interval Ω = [0, 1]. Assuming a fair wheel, it is appropriate to consider alloutcomes equally likely, but what is the probability of the event consisting of asingle element? It cannot be positive, because then, using the additivity axiom, itwould follow that events with a sufficiently large number of elements would haveprobability larger than 1. Therefore, the probability of any event that consists of asingle element must be 0.

In this example, it makes sense to assign probability b− a to any subinterval[a, b] of [0, 1], and to calculate the probability of a more complicated set by eval-

uating its “length.”† This assignment satisfies the three probability axioms andqualifies as a legitimate probability law.

Example 1.5. Romeo and Juliet have a date at a given time, and each will arriveat the meeting place with a delay between 0 and 1 hour, with all pairs of delaysbeing equally likely. The first to arrive will wait for 15 minutes and will leave if theother has not yet arrived. What is the probability that they will meet?

Let us use as sample space the square Ω = [0, 1]× [0, 1], whose elements arethe possible pairs of delays for the two of them. Our interpretation of “equallylikely” pairs of delays is to let the probability of a subset of Ω be equal to its area.This probability law satisfies the three probability axioms. The event that Romeoand Juliet will meet is the shaded region in Fig. 1.5, and its probability is calculatedto be 7/16.

Properties of Probability Laws

Probability laws have a number of properties, which can be deduced from theaxioms. Some of them are summarized below.

Some Properties of Probability Laws

Consider a probability law, and let A, B, and C be events.

(a) If A ⊂ B, then P(A) ≤ P(B).

(b) P(A ∪B) = P(A) + P(B) −P(A ∩B).

(c) P(A ∪B) ≤ P(A) + P(B).

(d) P(A ∪B ∪ C) = P(A) + P(Ac ∩B) + P(Ac ∩ Bc ∩C).

† The “length” of a subset S of [0, 1] is the integral∫

Sdt, which is defined, for

“nice” sets S, in the usual calculus sense. For unusual sets, this integral may not bewell defined mathematically, but such issues belong to a more advanced treatment ofthe subject.

Page 14: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

14 Sample Space and Probability Chap. 1

0 1

1

x

y

1/4

1/4

M

Figure 1.5: The event M that Romeo and Juliet will arrive within 15 minutesof each other (cf. Example 1.5) is

M =

(x, y)∣∣ |x− y| ≤ 1/4, 0 ≤ x ≤ 1, 0 ≤ y ≤ 1

,

and is shaded in the figure. The area of M is 1 minus the area of the two unshadedtriangles, or 1− (3/4) · (3/4) = 7/16. Thus, the probability of meeting is 7/16.

These properties, and other similar ones, can be visualized and verifiedgraphically using Venn diagrams, as in Fig. 1.6. For a further example, notethat we can apply property (c) repeatedly and obtain the inequality

P(A1 ∪ A2 ∪ · · · ∪ An) ≤n∑

i=1

P(Ai).

In more detail, let us apply property (c) to the sets A1 and A2 ∪ · · · ∪ An, toobtain

P(A1 ∪ A2 ∪ · · · ∪ An) ≤ P(A1) + P(A2 ∪ · · · ∪An).

We also apply property (c) to the sets A2 and A3 ∪ · · · ∪ An to obtain

P(A2 ∪ · · · ∪ An) ≤ P(A2) + P(A3 ∪ · · · ∪An),

continue similarly, and finally add.

Models and Reality

Using the framework of probability theory to analyze a physical but uncertainsituation, involves two distinct stages.

(a) In the first stage, we construct a probabilistic model, by specifying a prob-ability law on a suitably defined sample space. There are no hard rules to

Page 15: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.2 Probabilistic Models 15

A A B

A B

C

B

(a) (b)

(c)

A B A Bc

CA Bc c

A Bc

Figure 1.6: Visualization and verification of various properties of probabilitylaws using Venn diagrams. If A ⊂ B, then B is the union of the two disjointevents A and Ac ∩ B; see diagram (a). Therefore, by the additivity axiom, wehave

P(B) = P(A) + P(Ac ∩B) ≥ P(A),

where the inequality follows from the nonnegativity axiom, and verifies prop-erty (a).

From diagram (b), we can express the events A ∪ B and B as unions ofdisjoint events:

A ∪B = A ∪ (Ac ∩B), B = (A ∩B)∪ (Ac ∩B).

The additivity axiom yields

P(A ∪B) = P(A) + P(Ac ∩B), P(B) = P(A ∩B) + P(Ac ∩B).

Subtracting the second equality from the first and rearranging terms, we obtainP(A∪B) = P(A) +P(B)−P(A∩B), verifying property (b). Using also the factP(A ∩ B) ≥ 0 (the nonnegativity axiom), we obtain P(A ∪B) ≤ P(A) + P(B),verifying property (c)

From diagram (c), we see that the event A ∪B ∪ C can be expressed as aunion of three disjoint events:

A ∪B ∪ C = A ∪ (Ac ∩B) ∪ (Ac ∩Bc ∩ C),

so property (d) follows as a consequence of the additivity axiom.

Page 16: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

16 Sample Space and Probability Chap. 1

guide this step, other than the requirement that the probability law con-form to the three axioms. Reasonable people may disagree on which modelbest represents reality. In many cases, one may even want to use a some-what “incorrect” model, if it is simpler than the “correct” one or allows fortractable calculations. This is consistent with common practice in scienceand engineering, where the choice of a model often involves a tradeoff be-tween accuracy, simplicity, and tractability. Sometimes, a model is chosenon the basis of historical data or past outcomes of similar experiments.Systematic methods for doing so belong to the field of statistics, a topicthat we will touch upon in the last chapter of this book.

(b) In the second stage, we work within a fully specified probabilistic model andderive the probabilities of certain events, or deduce some interesting prop-erties. While the first stage entails the often open-ended task of connectingthe real world with mathematics, the second one is tightly regulated by therules of ordinary logic and the axioms of probability. Difficulties may arisein the latter if some required calculations are complex, or if a probabilitylaw is specified in an indirect fashion. Even so, there is no room for ambi-guity: all conceivable questions have precise answers and it is only a matterof developing the skill to arrive at them.

Probability theory is full of “paradoxes” in which different calculationmethods seem to give different answers to the same question. Invariably though,these apparent inconsistencies turn out to reflect poorly specified or ambiguousprobabilistic models.

1.3 CONDITIONAL PROBABILITY

Conditional probability provides us with a way to reason about the outcomeof an experiment, based on partial information. Here are some examples ofsituations we have in mind:

(a) In an experiment involving two successive rolls of a die, you are told thatthe sum of the two rolls is 9. How likely is it that the first roll was a 6?

(b) In a word guessing game, the first letter of the word is a “t”. What is thelikelihood that the second letter is an “h”?

(c) How likely is it that a person has a disease given that a medical test wasnegative?

(d) A spot shows up on a radar screen. How likely is it that it corresponds toan aircraft?

In more precise terms, given an experiment, a corresponding sample space,and a probability law, suppose that we know that the outcome is within somegiven event B. We wish to quantify the likelihood that the outcome also belongs

Page 17: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.3 Conditional Probability 17

to some other given event A. We thus seek to construct a new probability law,which takes into account this knowledge and which, for any event A, gives usthe conditional probability of A given B, denoted by P(A |B).

We would like the conditional probabilities P(A |B) of different events Ato constitute a legitimate probability law, that satisfies the probability axioms.They should also be consistent with our intuition in important special cases, e.g.,when all possible outcomes of the experiment are equally likely. For example,suppose that all six possible outcomes of a fair die roll are equally likely. If weare told that the outcome is even, we are left with only three possible outcomes,namely, 2, 4, and 6. These three outcomes were equally likely to start with,and so they should remain equally likely given the additional knowledge that theoutcome was even. Thus, it is reasonable to let

P(the outcome is 6 | the outcome is even) =1

3.

This argument suggests that an appropriate definition of conditional probabilitywhen all outcomes are equally likely, is given by

P(A |B) =number of elements of A ∩B

number of elements of B.

Generalizing the argument, we introduce the following definition of condi-tional probability:

P(A |B) =P(A ∩B)

P(B),

where we assume that P(B) > 0; the conditional probability is undefined if theconditioning event has zero probability. In words, out of the total probability ofthe elements of B, P(A |B) is the fraction that is assigned to possible outcomesthat also belong to A.

Conditional Probabilities Specify a Probability Law

For a fixed event B, it can be verified that the conditional probabilities P(A |B)form a legitimate probability law that satisfies the three axioms. Indeed, non-negativity is clear. Furthermore,

P(Ω |B) =P(Ω ∩B)

P(B)=

P(B)

P(B)= 1,

and the normalization axiom is also satisfied. In fact, since we have P(B |B) =P(B)/P(B) = 1, all of the conditional probability is concentrated on B. Thus,we might as well discard all possible outcomes outside B and treat the conditionalprobabilities as a probability law defined on the new universe B.

Page 18: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

18 Sample Space and Probability Chap. 1

To verify the additivity axiom, we write for any two disjoint events A1 andA2,

P(A1 ∪ A2 |B) =P

((A1 ∪ A2) ∩B

)

P(B)

=P((A1 ∩ B) ∪ (A2 ∩B))

P(B)

=P(A1 ∩B) + P(A2 ∩ B)

P(B)

=P(A1 ∩B)

P(B)+

P(A2 ∩B)

P(B)

= P(A1 |B) + P(A2 |B),

where for the second equality, we used the fact that A1 ∩ B and A2 ∩ B aredisjoint sets, and for the third equality we used the additivity axiom for the(unconditional) probability law. The argument for a countable collection ofdisjoint sets is similar.

Since conditional probabilities constitute a legitimate probability law, allgeneral properties of probability laws remain valid. For example, a fact such asP(A ∪ C) ≤ P(A) + P(C) translates to the new fact

P(A ∪C |B) ≤ P(A |B) + P(C |B).

Let us summarize the conclusions reached so far.

Properties of Conditional Probability

• The conditional probability of an event A, given an event B withP(B) > 0, is defined by

P(A |B) =P(A ∩B)

P(B),

and specifies a new (conditional) probability law on the same samplespace Ω. In particular, all known properties of probability laws remainvalid for conditional probability laws.

• Conditional probabilities can also be viewed as a probability law on anew universe B, because all of the conditional probability is concen-trated on B.

• In the case where the possible outcomes are finitely many and equallylikely, we have

P(A |B) =number of elements of A ∩ B

number of elements of B.

Page 19: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.3 Conditional Probability 19

Example 1.6. We toss a fair coin three successive times. We wish to find theconditional probability P(A |B) when A and B are the events

A = more heads than tails come up, B = 1st toss is a head.

The sample space consists of eight sequences,

Ω = HHH, HHT, HTH, HTT, THH, THT, TTH, TTT ,

which we assume to be equally likely. The event B consists of the four elementsHHH, HHT, HTH, HTT , so its probability is

P(B) =4

8.

The event A ∩ B consists of the three elements outcomes HHH, HHT, HTH , soits probability is

P(A ∩ B) =3

8.

Thus, the conditional probability P(A |B) is

P(A |B) =P(A ∩ B)

P(B)=

3/8

4/8=

3

4.

Because all possible outcomes are equally likely here, we can also compute P(A |B)using a shortcut. We can bypass the calculation of P(B) and P(A∩B), and simplydivide the number of elements shared by A and B (which is 3) with the number ofelements of B (which is 4), to obtain the same result 3/4.

Example 1.7. A fair 4-sided die is rolled twice and we assume that all sixteenpossible outcomes are equally likely. Let X and Y be the result of the 1st and the2nd roll, respectively. We wish to determine the conditional probability P(A |B)where

A =max(X,Y ) = m

, B =

min(X,Y ) = 2

,

and m takes each of the values 1, 2, 3, 4.As in the preceding example, we can first determine the probabilities P(A∩B)

and P(B) by counting the number of elements of A ∩ B and B, respectively, anddividing by 16. Alternatively, we can directly divide the number of elements ofA ∩ B with the number of elements of B; see Fig. 1.7.

Example 1.8. A conservative design team, call it C, and an innovative designteam, call it N, are asked to separately design a new product within a month. Frompast experience we know that:

(a) The probability that team C is successful is 2/3.

Page 20: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

20 Sample Space and Probability Chap. 1

11 2

2

3

3

4

4

All Outcomes Equally LikelyProbability = 1/16

1st Roll X

2nd Roll Y

B

Figure 1.7: Sample space of an experiment involving two rolls of a 4-sided die.(cf. Example 1.7). The conditioning event B = min(X, Y ) = 2 consists of the5-element shaded set. The set A = max(X, Y ) = m shares with B two elementsif m = 3 or m = 4, one element if m = 2, and no element if m = 1. Thus, we have

P(max(X, Y ) = m |B

)=

2/5 if m = 3 or m = 4,1/5 if m = 2,0 if m = 1.

(b) The probability that team N is successful is 1/2.

(c) The probability that at least one team is successful is 3/4.

If both teams are successful, the design of team N is adopted. Assuming that exactlyone successful design is produced, what is the probability that it was designed byteam N?

There are four possible outcomes here, corresponding to the four combinationsof success and failure of the two teams:

SS: both succeed, FF : both fail,SF : C succeeds, N fails, FS: C fails, N succeeds.

We are given that the probabilities of these outcomes satisfy

P(SS) + P(SF ) =2

3, P(SS) + P(FS) =

1

2, P(SS) + P(SF ) + P(FS) =

3

4.

From these relations, together with the normalization equation P(SS) + P(SF ) +P(FS) + P(FF ) = 1, we can obtain the probabilities of all the outcomes:

P(SS) =5

12, P(SF ) =

1

4, P(FS) =

1

12, P(FF ) =

1

4.

The desired conditional probability is

P(FS | SF,FS

)=

1

121

4+

1

12

=1

4.

Page 21: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.3 Conditional Probability 21

Using Conditional Probability for Modeling

When constructing probabilistic models for experiments that have a sequentialcharacter, it is often natural and convenient to first specify conditional prob-abilities and then use them to determine unconditional probabilities. The ruleP(A∩B) = P(B)P(A |B), which is a restatement of the definition of conditionalprobability, is often helpful in this process.

Example 1.9. Radar detection. If an aircraft is present in a certain area, aradar correctly registers its presence with probability 0.99. If it is not present, theradar falsely registers an aircraft presence with probability 0.10. We assume thatan aircraft is present with probability 0.05. What is the probability of false alarm(a false indication of aircraft presence), and the probability of missed detection(nothing registers, even though an aircraft is present)?

A sequential representation of the sample space is appropriate here, as shownin Fig. 1.8. Let A and B be the events

A = an aircraft is present,B = the radar registers an aircraft presence,

and consider also their complements

Ac = an aircraft is not present,Bc = the radar does not register an aircraft presence.

The given probabilities are recorded along the corresponding branches of the treedescribing the sample space, as shown in Fig. 1.8. Each event of interest correspondsto a leaf of the tree and its probability is equal to the product of the probabilitiesassociated with the branches in a path from the root to the corresponding leaf. Thedesired probabilities of false alarm and missed detection are

P(false alarm) = P(Ac ∩ B) = P(Ac)P(B |Ac) = 0.95 · 0.10 = 0.095,

P(missed detection) = P(A ∩Bc) = P(A)P(Bc |A) = 0.05 · 0.01 = 0.0005.

Extending the preceding example, we have a general rule for calculatingvarious probabilities in conjunction with a tree-based sequential description ofan experiment. In particular:

(a) We set up the tree so that an event of interest is associated with a leaf.We view the occurrence of the event as a sequence of steps, namely, thetraversals of the branches along the path from the root to the leaf.

(b) We record the conditional probabilities associated with the branches of thetree.

(c) We obtain the probability of a leaf by multiplying the probabilities recordedalong the corresponding path of the tree.

Page 22: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

22 Sample Space and Probability Chap. 1

P(A) = 0.05

P(Ac) = 0.95 False Alarm

MissedDetection

Aircraft Present

Aircraft not Present

Figure 1.8: Sequential description of the sample space for the radar detectionproblem in Example 1.9.

In mathematical terms, we are dealing with an event A which occurs if andonly if each one of several events A1, . . . , An has occurred, i.e., A = A1 ∩ A2 ∩· · · ∩ An. The occurrence of A is viewed as an occurrence of A1, followed bythe occurrence of A2, then of A3, etc, and it is visualized as a path on the treewith n branches, corresponding to the events A1, . . . , An. The probability of Ais given by the following rule (see also Fig. 1.9).

Multiplication Rule

Assuming that all of the conditioning events have positive probability, wehave

P(∩n

i=1 Ai

)= P(A1)P(A2 |A1)P(A3 |A1 ∩A2) · · ·P

(An | ∩n−1

i=1 Ai

).

The multiplication rule can be verified by writing

P(∩n

i=1 Ai

)= P(A1)

P(A1 ∩A2)

P(A1)

P(A1 ∩ A2 ∩A3)

P(A1 ∩ A2)· · ·

P(∩n

i=1 Ai

)

P(∩n−1

i=1 Ai

) ,

and by using the definition of conditional probability to rewrite the right-handside above as

P(A1)P(A2 |A1)P(A3 |A1 ∩A2) · · ·P(An | ∩n−1

i=1 Ai

).

Page 23: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.3 Conditional Probability 23

. . .A1 A2 A3 An-1 An

P(A1 ) P(A3 |A1 ∩A2 )P(A2 |A1 ) P(An |A1 ∩A2 ∩ ...∩ An-1)

Event A1 ∩A2 ∩A3 Event A1 ∩A2 ∩ ...∩ An

Figure 1.9: Visualization of the total probability theorem. The intersection eventA = A1∩A2∩· · ·∩An is associated with a path on the tree of a sequential descrip-tion of the experiment. We associate the branches of this path with the eventsA1, . . . , An, and we record next to the branches the corresponding conditionalprobabilities.

The final node of the path corresponds to the intersection event A, andits probability is obtained by multiplying the conditional probabilities recordedalong the branches of the path

P(A1 ∩A2 ∩ · · · ∩A3) = P(A1)P(A2 |A1) · · ·P(An |A1 ∩A2 ∩ · · · ∩ An−1).

Note that any intermediate node along the path also corresponds to some inter-section event and its probability is obtained by multiplying the correspondingconditional probabilities up to that node. For example, the event A1 ∩ A2 ∩ A3

corresponds to the node shown in the figure, and its probability is

P(A1 ∩A2 ∩A3) = P(A1)P(A2 |A1)P(A3 |A1 ∩A2).

For the case of just two events, A1 and A2, the multiplication rule is simply thedefinition of conditional probability.

Example 1.10. Three cards are drawn from an ordinary 52-card deck withoutreplacement (drawn cards are not placed back in the deck). We wish to find theprobability that none of the three cards is a heart. We assume that at each step,each one of the remaining cards is equally likely to be picked. By symmetry, thisimplies that every triplet of cards is equally likely to be drawn. A cumbersomeapproach, that we will not use, is to count the number of all card triplets thatdo not include a heart, and divide it with the number of all possible card triplets.Instead, we use a sequential description of the sample space in conjunction with themultiplication rule (cf. Fig. 1.10).

Define the events

Ai = the ith card is not a heart, i = 1, 2, 3.

We will calculate P(A1 ∩ A2 ∩ A3), the probability that none of the three cards isa heart, using the multiplication rule,

P(A1 ∩ A2 ∩ A3) = P(A1)P(A2 |A1)P(A3 |A1 ∩ A2).

Page 24: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

24 Sample Space and Probability Chap. 1

We have

P(A1) =39

52,

since there are 39 cards that are not hearts in the 52-card deck. Given that thefirst card is not a heart, we are left with 51 cards, 38 of which are not hearts, and

P(A2 |A1) =38

51.

Finally, given that the first two cards drawn are not hearts, there are 37 cards whichare not hearts in the remaining 50-card deck, and

P(A3 |A1 ∩ A2) =37

50.

These probabilities are recorded along the corresponding branches of the tree de-scribing the sample space, as shown in Fig. 1.10. The desired probability is nowobtained by multiplying the probabilities recorded along the corresponding path ofthe tree:

P(A1 ∩ A2 ∩ A3) =39

52· 38

51· 37

50.

Note that once the probabilities are recorded along the tree, the probabilityof several other events can be similarly calculated. For example,

P(1st is not a heart and 2nd is a heart) =39

52· 13

51,

P(1st two are not hearts and 3rd is a heart) =39

52· 38

51· 13

50.

Not a Heart39/52

38/51

37/50

Not a Heart

Not a Heart

Heart

Heart

Heart

13/52

13/51

13/50

Figure 1.10: Sequential description of the sample space of the 3-card selectionproblem in Example 1.10.

Page 25: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.4 Total Probability Theorem and Bayes’ Rule 25

Example 1.11. A class consisting of 4 graduate and 12 undergraduate studentsis randomly divided into 4 groups of 4. What is the probability that each groupincludes a graduate student? We interpret randomly to mean that given the as-signment of some students to certain slots, any of the remaining students is equallylikely to be assigned to any of the remaining slots. We then calculate the desiredprobability using the multiplication rule, based on the sequential description shownin Fig. 1.11. Let us denote the four graduate students by 1, 2, 3, 4, and considerthe events

A1 = students 1 and 2 are in different groups,A2 = students 1, 2, and 3 are in different groups,A3 = students 1, 2, 3, and 4 are in different groups.

We will calculate P(A3) using the multiplication rule:

P(A3) = P(A1 ∩ A2 ∩A3) = P(A1)P(A2 |A1)P(A3 |A1 ∩ A2).

We have

P(A1) =12

15,

since there are 12 student slots in groups other than the one of student 1, and thereare 15 student slots overall, excluding student 1. Similarly,

P(A2 |A1) =8

14,

since there are 8 student slots in groups other than the one of students 1 and 2,and there are 14 student slots, excluding students 1 and 2. Also,

P(A3 |A1 ∩ A2) =4

13,

since there are 4 student slots in groups other than the one of students 1, 2, and3, and there are 13 student slots, excluding students 1, 2, and 3. Thus, the desiredprobability is

12

15· 8

14· 4

13,

and is obtained by multiplying the conditional probabilities along the correspondingpath of the tree of Fig. 1.11.

1.4 TOTAL PROBABILITY THEOREM AND BAYES’ RULE

In this section, we explore some applications of conditional probability. We startwith the following theorem, which is often useful for computing the probabilitiesof various events, using a “divide-and-conquer” approach.

Page 26: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

26 Sample Space and Probability Chap. 1

Students 1 & 2 arein Different Groups

12/15

Students 1, 2, & 3 arein Different Groups

8/14

Students 1, 2, 3, & 4 arein Different Groups

4/13

Figure 1.11: Sequential description of the sample space of the student problemin Example 1.11.

Total Probability Theorem

Let A1, . . . ,An be disjoint events that form a partition of the sample space(each possible outcome is included in one and only one of the events A1, . . . , An)and assume that P(Ai) > 0, for all i = 1, . . . , n. Then, for any event B, wehave

P(B) = P(A1 ∩B) + · · ·+ P(An ∩B)

= P(A1)P(B |A1) + · · ·+ P(An)P(B |An).

The theorem is visualized and proved in Fig. 1.12. Intuitively, we are par-titioning the sample space into a number of scenarios (events) Ai. Then, theprobability that B occurs is a weighted average of its conditional probabilityunder each scenario, where each scenario is weighted according to its (uncondi-tional) probability. One of the uses of the theorem is to compute the probabilityof various events B for which the conditional probabilities P(B |Ai) are known oreasy to derive. The key is to choose appropriately the partition A1, . . . ,An, andthis choice is often suggested by the problem structure. Here are some examples.

Example 1.12. You enter a chess tournament where your probability of winninga game is 0.3 against half the players (call them type 1), 0.4 against a quarter ofthe players (call them type 2), and 0.5 against the remaining quarter of the players(call them type 3). You play a game against a randomly chosen opponent. Whatis the probability of winning?

Let Ai be the event of playing with an opponent of type i. We have

P(A1) = 0.5, P(A2) = 0.25, P(A3) = 0.25.

Page 27: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.4 Total Probability Theorem and Bayes’ Rule 27

A1B

A2 A3

A1A1 ∩B

B

A2 ∩B

A3 ∩B

A2

A3

Bc

Figure 1.12: Visualization and verification of the total probability theorem. Theevents A1, . . . , An form a partition of the sample space, so the event B can bedecomposed into the disjoint union of its intersections Ai ∩ B with the sets Ai,i.e.,

B = (A1 ∩B) ∪ · · · ∪ (An ∩B).

Using the additivity axiom, it follows that

P(B) = P(A1 ∩B) + · · ·+ P(An ∩B).

Since, by the definition of conditional probability, we have

P(Ai ∩B) = P(Ai)P(B |Ai),

the preceding equality yields

P(B) = P(A1)P(B |A1) + · · ·+ P(An)P(B |An).

For an alternative view, consider an equivalent sequential model, as shownon the right. The probability of the leaf Ai ∩B is the product P(Ai)P(B |Ai) ofthe probabilities along the path leading to that leaf. The event B consists of thethree highlighted leaves and P(B) is obtained by adding their probabilities.

Let also B be the event of winning. We have

P(B |A1) = 0.3, P(B |A2) = 0.4, P(B |A3) = 0.5.

Thus, by the total probability theorem, the probability of winning is

P(B) = P(A1)P(B |A1) + P(A2)P(B |A2) + P(A3)P(B |A3)

= 0.5 · 0.3 + 0.25 · 0.4 + 0.25 · 0.5

= 0.375.

Example 1.13. We roll a fair four-sided die. If the result is 1 or 2, we roll oncemore but otherwise, we stop. What is the probability that the sum total of ourrolls is at least 4?

Page 28: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

28 Sample Space and Probability Chap. 1

Let Ai be the event that the result of first roll is i, and note that P(Ai) = 1/4for each i. Let B be the event that the sum total is at least 4. Given the event A1,the sum total will be at least 4 if the second roll results in 3 or 4, which happenswith probability 1/2. Similarly, given the event A2, the sum total will be at least4 if the second roll results in 2, 3, or 4, which happens with probability 3/4. Also,given the event A3, we stop and the sum total remains below 4. Therefore,

P(B |A1) =1

2, P(B |A2) =

3

4, P(B |A3) = 0, P(B |A4) = 1.

By the total probability theorem,

P(B) =1

4· 1

2+

1

4· 3

4+

1

4· 0 +

1

4· 1 =

9

16.

The total probability theorem can be applied repeatedly to calculate proba-bilities in experiments that have a sequential character, as shown in the followingexample.

Example 1.14. Alice is taking a probability class and at the end of each weekshe can be either up-to-date or she may have fallen behind. If she is up-to-date ina given week, the probability that she will be up-to-date (or behind) in the nextweek is 0.8 (or 0.2, respectively). If she is behind in a given week, the probabilitythat she will be up-to-date (or behind) in the next week is 0.6 (or 0.4, respectively).Alice is (by default) up-to-date when she starts the class. What is the probabilitythat she is up-to-date after three weeks?

Let Ui and Bi be the events that Alice is up-to-date or behind, respectively,after i weeks. According to the total probability theorem, the desired probabilityP(U3) is given by

P(U3) = P(U2)P(U3 |U2) + P(B2)P(U3 |B2) = P(U2) · 0.8 + P(B2) · 0.4.

The probabilities P(U2) and P(B2) can also be calculated using the total probabilitytheorem:

P(U2) = P(U1)P(U2 |U1) + P(B1)P(U2 |B1) = P(U1) · 0.8 + P(B1) · 0.4,

P(B2) = P(U1)P(B2 |U1) + P(B1)P(B2 |B1) = P(U1) · 0.2 + P(B1) · 0.6.

Finally, since Alice starts her class up-to-date, we have

P(U1) = 0.8, P(B1) = 0.2.

We can now combine the preceding three equations to obtain

P(U2) = 0.8 · 0.8 + 0.2 · 0.4 = 0.72,

P(B2) = 0.8 · 0.2 + 0.2 · 0.6 = 0.28.

Page 29: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.4 Total Probability Theorem and Bayes’ Rule 29

and by using the above probabilities in the formula for P(U3):

P(U3) = 0.72 · 0.8 + 0.28 · 0.4 = 0.688.

Note that we could have calculated the desired probability P(U3) by con-structing a tree description of the experiment, by calculating the probability ofevery element of U3 using the multiplication rule on the tree, and by adding. Inexperiments with a sequential character one may often choose between using themultiplication rule or the total probability theorem for calculation of various prob-abilities. However, there are cases where the calculation based on the total prob-ability theorem is more convenient. For example, suppose we are interested inthe probability P(U20) that Alice is up-to-date after 20 weeks. Calculating thisprobability using the multiplication rule is very cumbersome, because the tree rep-resenting the experiment is 20-stages deep and has 220 leaves. On the other hand,with a computer, a sequential calculation using the total probability formulas

P(Ui+1) = P(Ui) · 0.8 + P(Bi) · 0.4,

P(Bi+1) = P(Ui) · 0.2 + P(Bi) · 0.6,

and the initial conditions P(U1) = 0.8, P(B1) = 0.2 is very simple.

The total probability theorem is often used in conjunction with the fol-lowing celebrated theorem, which relates conditional probabilities of the formP(A |B) with conditional probabilities of the form P(B |A), in which the orderof the conditioning is reversed.

Bayes’ Rule

Let A1, A2, . . . ,An be disjoint events that form a partition of the samplespace, and assume that P(Ai) > 0, for all i. Then, for any event B suchthat P(B) > 0, we have

P(Ai |B) =P(Ai)P(B |Ai)

P(B)

=P(Ai)P(B |Ai)

P(A1)P(B |A1) + · · ·+ P(An)P(B |An).

To verify Bayes’ rule, note that P(Ai)P(B |Ai) and P(Ai |B)P(B) areequal, because they are both equal to P(Ai ∩B). This yields the first equality.The second equality follows from the first by using the total probability theoremto rewrite P(B).

Bayes’ rule is often used for inference. There are a number of “causes”that may result in a certain “effect.” We observe the effect, and we wish to infer

Page 30: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

30 Sample Space and Probability Chap. 1

the cause. The events A1, . . . , An are associated with the causes and the event Brepresents the effect. The probability P(B |Ai) that the effect will be observedwhen the cause Ai is present amounts to a probabilistic model of the cause-effectrelation (cf. Fig. 1.13). Given that the effect B has been observed, we wish toevaluate the (conditional) probability P(Ai |B) that the cause Ai is present.

A1

B

A2 A3

Cause 1Malignant Tumor

Cause 3Other

Cause 2Nonmalignant

Tumor

EffectShade Observed

A1A1 ∩B

B

A2 ∩B

A3 ∩B

A2

A3

Bc

Figure 1.13: An example of the inference context that is implicit in Bayes’rule. We observe a shade in a person’s X-ray (this is event B, the “effect”) andwe want to estimate the likelihood of three mutually exclusive and collectivelyexhaustive potential causes: cause 1 (event A1) is that there is a malignant tumor,cause 2 (event A2) is that there is a nonmalignant tumor, and cause 3 (eventA3) corresponds to reasons other than a tumor. We assume that we know theprobabilities P(Ai) and P(B |Ai), i = 1, 2, 3. Given that we see a shade (eventB occurs), Bayes’ rule gives the conditional probabilities of the various causes as

P(Ai |B) =P(Ai)P(B |Ai)

P(A1)P(B |A1) + P(A2)P(B |A2) + P(A3)P(B |A3), i = 1, 2, 3.

For an alternative view, consider an equivalent sequential model, as shownon the right. The probability P(A1 |B) of a malignant tumor is the probabilityof the first highlighted leaf, which is P(A1 ∩B), divided by the total probabilityof the highlighted leaves, which is P(B).

Example 1.15. Let us return to the radar detection problem of Example 1.9 andFig. 1.8. Let

A =an aircraft is present,B =the radar registers an aircraft presence.

We are given that

P(A) = 0.05, P(B |A) = 0.99, P(B |Ac) = 0.1.

Page 31: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.5 Independence 31

Applying Bayes’ rule, with A1 = A and A2 = Ac, we obtain

P(aircraft present | radar registers) = P(A |B)

=P(A)P(B |A)

P(B)

=P(A)P(B |A)

P(A)P(B |A) + P(Ac)P(B |Ac)

=0.05 · 0.99

0.05 · 0.99 + 0.95 · 0.1

≈ 0.3426.

Example 1.16. Let us return to the chess problem of Example 1.12. Here Ai isthe event of getting an opponent of type i, and

P(A1) = 0.5, P(A2) = 0.25, P(A3) = 0.25.

Also, B is the event of winning, and

P(B |A1) = 0.3, P(B |A2) = 0.4, P(B |A3) = 0.5.

Suppose that you win. What is the probability P(A1 |B) that you had an opponentof type 1?

Using Bayes’ rule, we have

P(A1 |B) =P(A1)P(B |A1)

P(A1)P(B |A1) + P(A2)P(B |A2) + P(A3)P(B |A3)

=0.5 · 0.3

0.5 · 0.3 + 0.25 · 0.4 + 0.25 · 0.5

= 0.4.

1.5 INDEPENDENCE

We have introduced the conditional probability P(A |B) to capture the partialinformation that event B provides about event A. An interesting and importantspecial case arises when the occurrence of B provides no information and doesnot alter the probability that A has occurred, i.e.,

P(A |B) = P(A).

Page 32: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

32 Sample Space and Probability Chap. 1

When the above equality holds, we say that A is independent of B. Note thatby the definition P(A |B) = P(A ∩ B)/P(B), this is equivalent to

P(A ∩B) = P(A)P(B).

We adopt this latter relation as the definition of independence because it can beused even if P(B) = 0, in which case P(A |B) is undefined. The symmetry ofthis relation also implies that independence is a symmetric property; that is, ifA is independent of B, then B is independent of A, and we can unambiguouslysay that A and B are independent events.

Independence is often easy to grasp intuitively. For example, if the occur-rence of two events is governed by distinct and noninteracting physical processes,such events will turn out to be independent. On the other hand, independenceis not easily visualized in terms of the sample space. A common first thoughtis that two events are independent if they are disjoint, but in fact the oppositeis true: two disjoint events A and B with P(A) > 0 and P(B) > 0 are neverindependent, since their intersection A ∩ B is empty and has probability 0.

Example 1.17. Consider an experiment involving two successive rolls of a 4-sideddie in which all 16 possible outcomes are equally likely and have probability 1/16.

(a) Are the events

Ai = 1st roll results in i, Bj = 2nd roll results in j,

independent? We have

P(A ∩ B) = P(the result of the two rolls is (i, j)

)=

1

16,

P(Ai) =number of elements of Ai

total number of possible outcomes=

4

16,

P(Bj) =number of elements of Bj

total number of possible outcomes=

4

16.

We observe that P(Ai ∩Bj) = P(Ai)P(Bj), and the independence of Ai andBj is verified. Thus, our choice of the discrete uniform probability law (whichmight have seemed arbitrary) models the independence of the two rolls.

(b) Are the events

A = 1st roll is a 1, B = sum of the two rolls is a 5,

independent? The answer here is not quite obvious. We have

P(A ∩ B) = P(the result of the two rolls is (1,4)

)=

1

16,

and also

P(A) =number of elements of A

total number of possible outcomes=

4

16.

Page 33: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.5 Independence 33

The event B consists of the outcomes (1,4), (2,3), (3,2), and (4,1), and

P(B) =number of elements of B

total number of possible outcomes=

4

16.

Thus, we see that P(A ∩ B) = P(A)P(B), and the events A and B areindependent.

(c) Are the events

A = maximum of the two rolls is 2, B = minimum of the two rolls is 2,

independent? Intuitively, the answer is “no” because the minimum of the tworolls tells us something about the maximum. For example, if the minimum is2, the maximum cannot be 1. More precisely, to verify that A and B are notindependent, we calculate

P(A ∩ B) = P(the result of the two rolls is (2,2)

)=

1

16,

and also

P(A) =number of elements of A

total number of possible outcomes=

3

16,

P(B) =number of elements of B

total number of possible outcomes=

5

16.

We have P(A)P(B) = 15/(16)2, so that P(A ∩ B) 6= P(A)P(B), and A andB are not independent.

Conditional Independence

We noted earlier that the conditional probabilities of events, conditioned ona particular event, form a legitimate probability law. We can thus talk aboutindependence of various events with respect to this conditional law. In particular,given an event C , the events A and B are called conditionally independentif

P(A ∩ B |C) = P(A |C)P(B |C).

The definition of the conditional probability and the multiplication rule yield

P(A ∩ B |C) =P(A ∩ B ∩C)

P(C)

=P(C)P(B |C)P(A |B ∩C)

P(C)

= P(B |C)P(A |B ∩C).

Page 34: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

34 Sample Space and Probability Chap. 1

After canceling the factor P(B |C), assumed nonzero, we see that conditionalindependence is the same as the condition

P(A |B ∩ C) = P(A |C).

In words, this relation states that if C is known to have occurred, the additionalknowledge that B also occurred does not change the probability of A.

Interestingly, independence of two events A and B with respect to theunconditional probability law, does not imply conditional independence, andvice versa, as illustrated by the next two examples.

Example 1.18. Consider two independent fair coin tosses, in which all fourpossible outcomes are equally likely. Let

H1 = 1st toss is a head,H2 = 2nd toss is a head,D = the two tosses have different results.

The events H1 and H2 are (unconditionally) independent. But

P(H1 |D) =1

2, P(H2 |D) =

1

2, P(H1 ∩H2 |D) = 0,

so that P(H1 ∩ H2 |D) 6= P(H1 |D)P(H2 |D), and H1, H2 are not conditionallyindependent.

Example 1.19. There are two coins, a blue and a red one. We choose one ofthe two at random, each being chosen with probability 1/2, and proceed with twoindependent tosses. The coins are biased: with the blue coin, the probability ofheads in any given toss is 0.99, whereas for the red coin it is 0.01.

Let B be the event that the blue coin was selected. Let also Hi be the eventthat the ith toss resulted in heads. Given the choice of a coin, the events H1 andH2 are independent, because of our assumption of independent tosses. Thus,

P(H1 ∩H2 |B) = P(H1 |B)P(H2 |B) = 0.99 · 0.99.

On the other hand, the events H1 and H2 are not independent. Intuitively, if weare told that the first toss resulted in heads, this leads us to suspect that the bluecoin was selected, in which case, we expect the second toss to also result in heads.Mathematically, we use the total probability theorem to obtain

P(H1) = P(B)P(H1 |B) + P(Bc)P(H1 |Bc

) =1

2· 0.99 +

1

2· 0.01 =

1

2,

Page 35: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.5 Independence 35

as should be expected from symmetry considerations. Similarly, we have P(H2) =1/2. Now notice that

P(H1 ∩H2) = P(B)P(H1 ∩H2 |B) + P(Bc)P(H1 ∩H2 |Bc)

=1

2· 0.99 · 0.99 +

1

2· 0.01 · 0.01 ≈ 1

2.

Thus, P(H1 ∩H2) 6= P(H1)P(H2), and the events H1 and H2 are dependent, eventhough they are conditionally independent given B.

As mentioned earlier, if A and B are independent, the occurrence of B doesnot provide any new information on the probability of A occurring. It is thenintuitive that the non-occurrence of B should also provide no information on theprobability of A. Indeed, it can be verified that if A and B are independent, thesame holds true for A and Bc (see the end-of-chapter problems).

We now summarize.

Independence

• Two events A and B are said to independent if

P(A ∩B) = P(A)P(B).

If in addition, P(B) > 0, independence is equivalent to the condition

P(A |B) = P(A).

• If A and B are independent, so are A and Bc.

• Two events A and B are said to be conditionally independent, givenanother event C with P(C) > 0, if

P(A ∩ B |C) = P(A |C)P(B |C).

If in addition, P(B ∩ C) > 0, conditional independence is equivalentto the condition

P(A |B ∩C) = P(A |C).

• Independence does not imply conditional independence, and vice versa.

Independence of a Collection of Events

The definition of independence can be extended to multiple events.

Page 36: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

36 Sample Space and Probability Chap. 1

Definition of Independence of Several Events

We say that the events A1, A2, . . . , An are independent if

P

(⋂

i∈S

Ai

)=

i∈S

P(Ai), for every subset S of 1, 2, . . . , n.

If we have a collection of three events, A1, A2, and A3, independenceamounts to satisfying the four conditions

P(A1 ∩A2) = P(A1)P(A2),

P(A1 ∩A3) = P(A1)P(A3),

P(A2 ∩A3) = P(A2)P(A3),

P(A1 ∩A2 ∩A3) = P(A1)P(A2)P(A3).

The first three conditions simply assert that any two events are independent,a property known as pairwise independence. But the fourth condition isalso important and does not follow from the first three. Conversely, the fourthcondition does not imply the first three; see the two examples that follow.

Example 1.20. Pairwise independence does not imply independence.Consider two independent fair coin tosses, and the following events:

H1 = 1st toss is a head,H2 = 2nd toss is a head,D = the two tosses have different results.

The events H1 and H2 are independent, by definition. To see that H1 and D areindependent, we note that

P(D |H1) =P(H1 ∩D)

P(H1)=

1/4

1/2=

1

2= P(D).

Similarly, H2 and D are independent. On the other hand, we have

P(H1 ∩H2 ∩D) = 0 6= 1

2· 1

2· 1

2= P(H1)P(H2)P(D),

and these three events are not independent.

Example 1.21. The equality P(A1 ∩ A2 ∩ A3) = P(A1)P(A2)P(A3) is notenough for independence. Consider two independent rolls of a fair die, and

Page 37: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.5 Independence 37

the following events:

A = 1st roll is 1, 2, or 3,B = 1st roll is 3, 4, or 5,C = the sum of the two rolls is 9.

We have

P(A ∩B) =1

66= 1

2· 1

2= P(A)P(B),

P(A ∩ C) =1

366= 1

2· 4

36= P(A)P(C),

P(B ∩ C) =1

126= 1

2· 4

36= P(B)P(C).

Thus the three events A, B, and C are not independent, and indeed no two of theseevents are independent. On the other hand, we have

P(A ∩ B ∩ C) =1

36=

1

2· 1

2· 4

36= P(A)P(B)P(C).

The intuition behind the independence of a collection of events is anal-ogous to the case of two events. Independence means that the occurrence ornon-occurrence of any number of the events from that collection carries noinformation on the remaining events or their complements. For example, if theevents A1,A2, A3, A4 are independent, one obtains relations such as

P(A1 ∪A2 |A3 ∩ A4) = P(A1 ∪ A2)

or

P(A1 ∪ Ac2 |Ac

3 ∩A4) = P(A1 ∪Ac2);

see the end-of-chapter problems.

Reliability

In probabilistic models of complex systems involving several components, it isoften convenient to assume that the components behave “independently” of eachother. This typically simplifies the calculations and the analysis, as illustratedin the following example.

Example 1.22. Network connectivity. A computer network connects twonodes A and B through intermediate nodes C, D, E, F, as shown in Fig. 1.14(a).For every pair of directly connected nodes, say i and j, there is a given probabilitypij that the link from i to j is up. We assume that link failures are independent

Page 38: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

38 Sample Space and Probability Chap. 1

A B

C

F

E

D

0.9

0.8

0.95

0.9

0.85

0.75

(a)

(b)Series Connection Parallel Connection

1 2 3

1

2

3

0.95

Figure 1.14: (a) Network for Example 1.22. The number next to each link(i, j) indicates the probability that the link is up. (b) Series and parallelconnections of three components in a reliability problem.

of each other. What is the probability that there is a path connecting A and B inwhich all links are up?

This is a typical problem of assessing the reliability of a system consisting ofcomponents that can fail independently. Such a system can often be divided intosubsystems, where each subsystem consists in turn of several components that areconnected either in series or in parallel; see Fig. 1.14(b).

Let a subsystem consist of components 1, 2, . . . , m, and let pi be the prob-ability that component i is up (“succeeds”). Then, a series subsystem succeedsif all of its components are up, so its probability of success is the product of theprobabilities of success of the corresponding components, i.e.,

P(series subsystem succeeds) = p1p2 · · · pm.

A parallel subsystem succeeds if any one of its components succeeds, so its prob-ability of failure is the product of the probabilities of failure of the correspondingcomponents, i.e.,

P(parallel subsystem succeeds) = 1−P(parallel subsystem fails)

= 1− (1− p1)(1− p2) · · · (1− pm).

Returning now to the network of Fig. 1.14(a), we can calculate the probabil-ity of success (a path from A to B is available) sequentially, using the precedingformulas, and starting from the end. Let us use the notation X → Y to denote the

Page 39: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.5 Independence 39

event that there is a (possibly indirect) connection from node X to node Y . Then,

P(C → B) = 1 −(1 −P(C → E and E → B)

)(1 −P(C → F and F → B)

)

= 1 − (1− pCEpEB)(1− pCF pFB)

= 1 − (1− 0.8 · 0.9)(1 − 0.85 · 0.95)

= 0.946,

P(A → C and C → B) = P(A → C)P(C → B) = 0.9 · 0.946 = 0.851,

P(A → D and D → B) = P(A → D)P(D → B) = 0.75 · 0.95 = 0.712,

and finally we obtain the desired probability

P(A → B) = 1 −(1 −P(A → C and C → B)

)(1 −P(A → D and D → B)

)

= 1 − (1− 0.851)(1 − 0.712)

= 0.957.

Independent Trials and the Binomial Probabilities

If an experiment involves a sequence of independent but identical stages, we saythat we have a sequence of independent trials. In the special case where thereare only two possible results at each stage, we say that we have a sequence ofindependent Bernoulli trials. The two possible results can be anything, e.g.,“it rains” or “it doesn’t rain,” but we will often think in terms of coin tosses andrefer to the two results as “heads” (H) and “tails” (T ).

Consider an experiment that consists of n independent tosses of a biasedcoin, in which the probability of “heads” is p, where p is some number between0 and 1. In this context, independence means that the events A1, A2, . . . , An areindependent, where Ai = ith toss is a head.

We can visualize independent Bernoulli trials by means of a sequentialdescription, as shown in Fig. 1.15 for the case where n = 3. The conditionalprobability of any toss being a head, conditioned on the results of any preced-ing tosses is p, because of independence. Thus, by multiplying the conditionalprobabilities along the corresponding path of the tree, we see that any particularoutcome (3-long sequence of heads and tails) that involves k heads and 3 − ktails has probability pk(1− p)3−k. This formula extends to the case of a generalnumber n of tosses. We obtain that the probability of any particular n-longsequence that contains k heads and n− k tails is pk(1− p)n−k, for all k from 0to n.

Let us now consider the probability

p(k) = P(k heads come up in an n-toss sequence),

Page 40: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

40 Sample Space and Probability Chap. 1

p

p

p

p

p

p

p

1 - p

1 - p

1 - p

1 - p

1 - p

1 - p

1 - p

HHH

HHT

HTH

HTT

THH

THT

TTH

TTT

Prob = p2(1 - p)

Prob = p3

Prob = (1 - p)3

Prob = p(1 - p)2

Prob = p2(1 - p)

Prob = p2(1 - p)

Prob = p(1 - p)2

Prob = p(1 - p)2

HH

HT

TH

TT

H

T

Figure 1.15: Sequential description of the sample space of an experiment involv-ing three independent tosses of a biased coin. Along the branches of the tree,we record the corresponding conditional probabilities, and by the multiplicationrule, the probability of obtaining a particular 3-toss sequence is calculated bymultiplying the probabilities recorded along the corresponding path of the tree.

which will play an important role later. We showed above that the probabilityof any given sequence that contains k heads is pk(1 − p)n−k, so we have

p(k) =

(n

k

)pk(1− p)n−k,

where

(n

k

)= number of distinct n-toss sequences that contain k heads.

The numbers(n

k

)(called “n choose k”) are known as the binomial coefficients,

while the probabilities p(k) are known as the binomial probabilities. Using acounting argument, to be given in Section 1.6, one finds that

(n

k

)=

n!

k! (n− k)!, k = 0,1, . . . , n,

where for any positive integer i we have

i! = 1 · 2 · · · (i − 1) · i,

Page 41: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.6 Counting∗ 41

and, by convention, 0! = 1. An alternative verification is sketched in the end-of-chapter problems. Note that the binomial probabilities p(k) must add to 1, thusshowing the binomial formula

n∑

k=0

(n

k

)pk(1− p)n−k = 1.

Example 1.23. Grade of service. An internet service provider has installed cmodems to serve the needs of a population of n customers. It is estimated that at agiven time, each customer will need a connection with probability p, independentlyof the others. What is the probability that there are more customers needing aconnection than there are modems?

Here we are interested in the probability that more than c customers simul-taneously need a connection. It is equal to

n∑

k=c+1

p(k),

where

p(k) =

(n

k

)pk(1− p)n−k

are the binomial probabilities.This example is typical of problems of sizing the capacity of a facility to

serve the needs of a homogeneous population, consisting of independently actingcustomers. The problem is to select the size c to achieve a certain threshold prob-ability (sometimes called grade of service) that no user is left unserved.

1.6 COUNTING∗

The calculation of probabilities often involves counting of the number of out-comes in various events. We have already seen two contexts where such countingarises.

(a) When the sample space Ω has a finite number of equally likely outcomes,so that the discrete uniform probability law applies. Then, the probabilityof any event A is given by

P(A) =Number of elements of A

Number of elements of Ω,

and involves counting the elements of A and of Ω.

(b) When we want to calculate the probability of an event A with a finitenumber of equally likely outcomes, each of which has an already knownprobability p. Then the probability of A is given by

P(A) = p · (Number of elements of A),

Page 42: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

42 Sample Space and Probability Chap. 1

and involves counting of the number of elements of A. An example of thistype is the calculation of the probability of k heads in n coin tosses (thebinomial probabilities). We saw there that the probability of each distinctsequence involving k heads is easily obtained, but the calculation of thenumber of all such sequences is somewhat intricate, as will be seen shortly.

While counting is in principle straightforward, it is frequently challenging;the art of counting constitutes a large portion of a field known as combinatorics.In this section, we present the basic principle of counting and apply it to a numberof situations that are often encountered in probabilistic models.

The Counting Principle

The counting principle is based on a divide-and-conquer approach, whereby thecounting is broken down into stages through the use of a tree. For example,consider an experiment that consists of two consecutive stages. The possibleresults of the first stage are a1, a2, . . . , am; the possible results of the secondstage are b1, b2, . . . , bn. Then, the possible results of the two-stage experimentare all possible ordered pairs (ai, bj), i = 1, . . . , m, j = 1, . . . , n. Note that thenumber of such ordered pairs is equal to mn. This observation can be generalizedas follows (see also Fig. 1.16).

Leaves

. . . . . .

. . . . . .

. . . . . .

. . . .

Stage 1 Stage 2 Stage 3 Stage 4

n1Choices

n2Choices

n3Choices

n4Choices

Figure 1.16: Illustration of the basic counting principle. The counting is carriedout in r stages (r = 4 in the figure). The first stage has n1 possible results. Forevery possible result of the first i− 1 stages, there are ni possible results at theith stage. The number of leaves is n1n2 · · ·nr. This is the desired count.

Page 43: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.6 Counting∗ 43

The Counting Principle

Consider a process that consists of r stages. Suppose that:

(a) There are n1 possible results for the first stage.

(b) For every possible result of the first stage, there are n2 possible resultsat the second stage.

(c) More generally, for all possible results of the first i − 1 stages, thereare ni possible results at the ith stage.

Then, the total number of possible results of the r-stage process is

n1 · n2 · · ·nr.

Example 1.24. The number of telephone numbers. A telephone numberis a 7-digit sequence, but the first digit has to be different from 0 or 1. How manydistinct telephone numbers are there? We can visualize the choice of a sequenceas a sequential process, where we select one digit at a time. We have a total of 7stages, and a choice of one out of 10 elements at each stage, except for the firststage where we only have 8 choices. Therefore, the answer is

8 · 10 · 10 · · · 10︸ ︷︷ ︸6 times

= 8 · 106.

Example 1.25. The number of subsets of an n-element set. Consider ann-element set s1, s2, . . . , sn. How many subsets does it have (including itself andthe empty set)? We can visualize the choice of a subset as a sequential processwhere we examine one element at a time and decide whether to include it in the setor not. We have a total of n stages, and a binary choice at each stage. Thereforethe number of subsets is

2 · 2 · · · 2︸ ︷︷ ︸n times

= 2n.

It should be noted that the Counting Principle remains valid even if eachfirst-stage result leads to a different set of potential second-stage results, etc. Theonly requirement is that the number of possible second-stage results is constant,regardless of the first-stage result. This observation is used in the sequel.

In what follows, we will focus primarily on two types of counting argumentsthat involve the selection of k objects out of a collection of n objects. If the orderof selection matters, the selection is called a permutation, and otherwise, it is

Page 44: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

44 Sample Space and Probability Chap. 1

called a combination. We will then discuss a more general type of counting,involving a partition of a collection of n objects into multiple subsets.

k-permutations

We start with n distinct objects, and let k be some positive integer, with k ≤ n.We wish to count the number of different ways that we can pick k out of thesen objects and arrange them in a sequence, i.e., the number of distinct k-objectsequences. We can choose any of the n objects to be the first one. Having chosenthe first, there are only n− 1 possible choices for the second; given the choice ofthe first two, there only remain n − 2 available objects for the third stage, etc.When we are ready to select the last (the kth) object, we have already chosenk − 1 objects, which leaves us with n− (k − 1) choices for the last one. By theCounting Principle, the number of possible sequences, called k-permutations,is

n(n− 1) · · · (n− k + 1) =n(n− 1) · · · (n− k + 1)(n− k) · · · 2 · 1

(n− k) · · · 2 · 1

=n!

(n− k)!.

In the special case where k = n, the number of possible sequences, simply calledpermutations, is

n · (n− 1) · (n− 2) · · · 2 · 1 = n!.

(Let k = n in the formula for the number of k-permutations, and recall theconvention 0! = 1.)

Example 1.26. Let us count the number of words that consist of four distinctletters. This is the problem of counting the number of 4-permutations of the 26letters in the alphabet. The desired number is

n!

(n − k)!=

26!

22!= 26 · 25 · 24 · 23 = 358, 800.

The count for permutations can be combined with the Counting Principleto solve more complicated counting problems.

Example 1.27. You have n1 classical music CDs, n2 rock music CDs, and n3

country music CDs. In how many different ways can you arrange them so that theCDs of the same type are contiguous?

We break down the problem in two stages, where we first select the order ofthe CD types, and then the order of the CDs of each type. There are 3! ordered se-quences of the types of CDs (such as classical/rock/country, rock/country/classical,etc), and there are n1! (or n2!, or n3!) permutations of the classical (or rock, or

Page 45: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.6 Counting∗ 45

country, respectively) CDs. Thus for each of the 3! CD type sequences, there aren1!n2! n3! arrangements of CDs, and the desired total number is 3! n1!n2! n3!.

Combinations

There are n people and we are interested in forming a committee of k. Howmany different committees are there? More abstractly, this is the same as theproblem of counting the number of k-element subsets of a given n-element set.Notice that forming a combination is different than forming a k-permutation,because in a combination there is no ordering of the selected elements.Thus for example, whereas the 2-permutations of the letters A, B, C, and D are

AB, AC, AD, BA, BC, BD, CA, CB, CD, DA, DB, DC,

the combinations of two out of four of these letters are

AB, AC, AD, BC, BD, CD.

There is a close connection between the number of combinations and thebinomial coefficient that was introduced in Section 1.5. To see this note thatspecifying an n-toss sequence with k heads is the same as picking k elements(those that correspond to heads) out of the n-element set of tosses. Thus, thenumber of combinations is the same as the binomial coefficient

(nk

)introduced

in Section 1.5.To count the number of combinations, note that selecting a k-permutation

is the same as first selecting a combination of k items and then ordering them.Since there are k! ways of ordering the k selected items, we see that the numberof k-permutations is equal to the number of combinations times k!. Hence, thenumber of possible combinations, is given by

(n

k

)=

n!

k! (n− k)!.

Example 1.28. The number of combinations of two out of the four letters A, B,C, and D is found by letting n = 4 and k = 2. It is

(4

2

)=

4!

2! 2!= 6,

consistently with the listing given earlier.

It is worth observing that counting arguments sometimes lead to formulasthat are rather difficult to derive algebraically. One example is the binomialformula

n∑

k=0

(n

k

)pk(1 − p)n−k = 1

Page 46: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

46 Sample Space and Probability Chap. 1

discussed in Section 1.5. Here is another example. Since(n

k

)is the number of

k-element subsets of a given n-element subset, the sum over k of(nk

)counts the

number of subsets of all possible cardinalities. It is therefore equal to the numberof all subsets of an n-element set, which is 2n, and we obtain

n∑

k=0

(n

k

)= 2n.

Partitions

Recall that a combination is a choice of k elements out of an n-element setwithout regard to order. This is the same as partitioning the set in two: onepart contains k elements and the other contains the remaining n − k. We nowgeneralize by considering partitions in more than two subsets.

We have n distinct objects and we are given nonnegative integers n1, n2, . . . ,nr, whose sum is equal to n. The n items are to be divided into r disjoint groups,with the ith group containing exactly ni items. Let us count in how many waysthis can be done.

We form the groups one at a time. We have(

nn1

)ways of forming the first

group. Having formed the first group, we are left with n− n1 objects. We needto choose n2 of them in order to form the second group, and we have

(n−n1n2

)

choices, etc. Using the Counting Principle for this r-stage process, the totalnumber of choices is

(n

n1

)(n− n1

n2

)(n− n1 − n2

n3

)· · ·

(n− n1 − · · · − nr−1

nr

),

which is equal to

n!

n1! (n− n1)!

(n− n1)!

n2! (n− n1 − n2)!· · · (n− n1 − · · · − nr−1)!

(n− n1 − · · · − nr−1 − nr)!nr!.

We note that several terms cancel and we are left with

n!

n1! n2! · · ·nr!.

This is called the multinomial coefficient and is usually denoted by

(n

n1, n2, . . . , nr

).

Example 1.29. Anagrams. How many different letter sequences can be obtainedby rearranging the letters in the word TATTOO? There are six positions to be filled

Page 47: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.6 Counting∗ 47

by the available letters. Each rearrangement corresponds to a partition of the set ofthe six positions into a group of size 3 (the positions that get the letter T), a groupof size 1 (the position that gets the letter A), and a group of size 2 (the positionsthat get the letter O). Thus, the desired number is

6!

1! 2! 3!=

1 · 2 · 3 · 4 · 5 · 61 · 1 · 2 · 1 · 2 · 3 = 60.

It is instructive to rederive this answer using an alternative argument. (Thisargument can also be used to rederive the multinomial coefficient formula; see theend-of-chapter problems.) Let us rewrite TATTOO in the form T1AT2T3O1O2

pretending for a moment that we are dealing with 6 distinguishable objects. These6 objects can be rearranged in 6! different ways. However, any of the 3! possiblepermutations of T1, T1, and T3, as well as any of the 2! possible permutations ofO1 and O2, lead to the same word. Thus, when the subscripts are removed, thereare only 6!/(3! 2!) different words.

Example 1.30. A class consisting of 4 graduate and 12 undergraduate studentsis randomly divided into four groups of 4. What is the probability that each groupincludes a graduate student? This is the same as Example 1.11 in Section 1.3, butwe will now obtain the answer using a counting argument.

We first determine the nature of the sample space. A typical outcome is aparticular way of partitioning the 16 students into four groups of 4. We take theterm “randomly” to mean that every possible partition is equally likely, so that theprobability question can be reduced to one of counting.

According to our earlier discussion, there are

(16

4, 4, 4, 4

)=

16!

4! 4! 4! 4!

different partitions, and this is the size of the sample space.Let us now focus on the event that each group contains a graduate student.

Generating an outcome with this property can be accomplished in two stages:

(a) Take the four graduate students and distribute them to the four groups; thereare four choices for the group of the first graduate student, three choices forthe second, two for the third. Thus, there is a total of 4! choices for this stage.

(b) Take the remaining 12 undergraduate students and distribute them to thefour groups (3 students in each). This can be done in

(12

3, 3, 3, 3

)=

12!

3! 3! 3! 3!

different ways.

By the Counting Principle, the event of interest can materialize in

4! 12!

3! 3! 3! 3!

Page 48: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

48 Sample Space and Probability Chap. 1

different ways. The probability of this event is

4! 12!

3! 3! 3! 3!

16!

4! 4! 4! 4!

.

After some cancellations, we can see that this is the same as the answer 12 · 8 ·4/(15 · 14 · 13) obtained in Example 1.11.

Here is a summary of all the counting results we have developed.

Summary of Counting Results

• Permutations of n objects: n!

• k-permutations of n objects: n!/(n− k)!

• Combinations of k out of n objects:

(n

k

)=

n!

k!(n− k)!

• Partitions of n objects into r groups with the ith group having ni

objects: (n

n1, n2, . . . , nr

)=

n!

n1! n2! · · ·nr!.

1.7 SUMMARY AND DISCUSSION

A probability problem can usually be broken down into a few basic steps:

1. The description of the sample space, that is, the set of possible outcomesof a given experiment.

2. The (possibly indirect) specification of the probability law (the probabilityof each event).

3. The calculation of probabilities and conditional probabilities of variousevents of interest.

The probabilities of events must satisfy the nonnegativity, additivity, and nor-malization axioms. In the important special case where the set of possible out-comes is finite, one can just specify the probability of each outcome and obtainthe probability of any event by adding the probabilities of the elements of theevent.

Conditional probabilities can be viewed as probability laws on the samesample space. We can also view the conditioning event as a new universe, be-

Page 49: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 49

cause only outcomes contained in the conditioning event can have positive condi-tional probability. Conditional probabilities are derived from the (unconditional)probability law using the definition P(A |B) = P(A ∩ B)/P(B). However, thereverse process is often convenient, that is, first specify some conditional proba-bilities that are natural for the real situation that we wish to model, and thenuse them to derive the (unconditional) probability law. Two important tools inthis context are the multiplication rule and the total probability theorem.

We have illustrated through examples three methods of specifying proba-bility laws in probabilistic models:

(1) The counting method. This method applies to the case where the num-ber of possible outcomes is finite, and all outcomes are equally likely. Tocalculate the probability of an event, we count the number of elements inthe event and divide by the number of elements of the sample space.

(2) The sequential method. This method applies when the experiment has asequential character, and suitable conditional probabilities are specified orcalculated along the branches of the corresponding tree (perhaps using thecounting method). The probabilities of various events are then obtainedby multiplying conditional probabilities along the corresponding paths ofthe tree, using the multiplication rule.

(3) The divide-and-conquer method. Here, the probabilities P(B) of vari-ous events B are obtained from conditional probabilities P(B |Ai), wherethe Ai are suitable events that form a partition of the sample space andhave known probabilities P(Ai). The probabilities P(B) are then obtainedby using the total probability theorem.

Finally, we have focused on a few side topics that reinforce our main themes.We have discussed the use of Bayes’ rule in inference, which is an importantapplication context. We have also discussed some basic principles of countingand combinatorics, which are helpful in applying the counting method.

Page 50: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

50 Sample Space and Probability Chap. 1

S O L V E D P R O B L E M S

SECTION 1.1. Sets

Problem 1. * Prove the identity A ∪(∩∞n=1 Bn

)= ∩∞n=1(A ∪ Bn).

Solution. If x belongs to the set on the left, there are two possibilities. Either x ∈ A,in which case it belongs to all of the sets A ∪ Bn, and therefore belongs to the set onthe right. Alternatively, x belongs to all of the sets Bn in which case, it belongs to allof the sets A ∪ Bn, and therefore again belongs to the set on the right.

Conversely, if x belongs to the set on the right, then it belongs to A ∪Bn for alln. If x belongs to A, then it belongs to the set on the left. Otherwise, x must belongto every set Bn and again belongs to the set on the left.

Problem 2. * Cantor’s diagonalization argument. Show that the set [0, 1] isuncountable, that is, its elements cannot be arranged in a sequence.

Solution. Any number x in [0, 1] can be represented in terms of its decimal expansion,e.g., 1/3 = 0.3333 · · ·. Note that most numbers have a unique decimal expansion,but there are a few exceptions. For example, 1/2 can be represented as 0.5000 · · · oras 0.49999 · · ·. It can be shown that this is the only kind of exception, i.e., decimalexpansions that end with an infinite string of zeroes or an infinite string of nines.

Suppose to derive a contradiction, that the elements of [0, 1] can be arranged in asequence x1, x2, x3, . . ., so that every element of [0, 1] appears in the sequence. Considerthe decimal expansion of xn:

xn = 0.a1na2

na3n · · · ,

where each digit ain belongs to 0, 1, . . . , 9. Consider now a number y constructed as

follows. The nth digit of y can be 1 or 2, and is chosen so that it is different from thenth digit of xn. Note that y has a unique decimal expansion since it does not end withan infinite sequence of zeroes or nines. The number y differs from each xn, since it hasa different nth digit. Therefore, the sequence x1, x2, . . . does not exhaust the elementsof [0, 1], contrary to what was assumed. The contradiction establishes that the set [0, 1]is uncountable.

SECTION 1.2. Probabilistic Models

Problem 3. Out of the students in a class, 60% are geniuses, 70% love chocolate,and 40% fall into both categories. Determine the probability that a randomly selectedstudent is neither a genius nor a chocolate lover.

Solution. Let G and C be the events that the chosen student is a genius and a chocolatelover, respectively. We have P(G) = 0.6, P(C) = 0.7, and P(G ∩ C) = 0.4. We areinterested in P(Gc ∩ Cc), which is obtained with the following calculation:

P(Gc∩Cc) = 1−P(G∪C) = 1−(P(G)+P(C)−P(G∩C)

)= 1−(0.6+0.7−0.4) = 0.1.

Page 51: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 51

Problem 4. A six-sided die is loaded in a way that each even face is twice as likelyas each odd face. All even faces are equally likely, as are all odd faces. Construct aprobabilistic model for a single roll of this die and find the probability that the outcomeis less than 4.

Solution. We first determine the probabilities of the six possible outcomes. Let a =P(1) = P(3) = P(5) and b = P(2) = P(4) = P(6). We are given thatb = 2a. By the additivity and normalization axioms, 1 = 3a + 3b = 3a + 6a = 9a.Thus, a = 1/9, b = 2/9, and P(1, 2, 3) = 4/9.

Problem 5. A four-sided die is rolled repeatedly, until the first time (if ever) thatan even number is obtained. What is the sample space for this experiment?

Solution. The outcome of this experiment can be any finite sequence of the form(a1, a2, . . . , an), where n is an arbitrary positive integer, a1, a2, . . . , an−1 belong to1, 3, and an belongs to 2, 4. In addition, there are possible outcomes in whichan even number is never obtained. Such outcomes are infinite sequences (a1, a2, . . .),with each element in the sequence belonging to 1, 3. The sample space consists of allpossible outcomes of the above two types.

Problem 6. * Bonferroni’s inequality.

(a) Prove that for any two events A and B, we have

P(A ∩ B) ≥ P(A) + P(B) − 1.

(b) Generalize to the case of n events A1, A2, . . . , An, by showing that

P(A1 ∩A2 ∩ · · · ∩ An) ≥ P(A1) + P(A2) + · · ·+ P(An) − (n− 1).

Solution. We have P(A ∪ B) = P(A) + P(B) − P(A ∩ B) and P(A ∪ B) ≤ 1, whichimplies part (a). For part (b), we use de Morgan’s law to obtain

1 −P(A1 ∩ · · · ∩ An) = P((A1 ∩ · · · ∩An)c

)

= P(Ac1 ∪ · · · ∪ Ac

n)

≤ P(Ac1) + · · · + P(A

cn)

=(1 −P(A1)

)+ · · · +

(1 −P(An)

)

= n−P(A1)− · · · −P(An).

Problem 7. * Continuity property of probabilities

(a) Let A1, A2, . . . be an infinite sequence of events, which is “monotonically increas-ing,” meaning that An ⊂ An+1 for every n. Let A = ∪∞n=1An. Show thatP(A) = limn→∞P(An).

(b) Suppose now that the events are “monotonically decreasing,” i.e., An+1 ⊂ An

for every n. Let A = ∩∞n=1An. Show that P(A) = limn→∞P(An).

Page 52: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

52 Sample Space and Probability Chap. 1

(c) Consider an experiment whose sample space is the real line. Show that

P([0,∞)

)= lim

n→∞P

([0, n]

)and lim

n→∞P

([n,∞)

)= 0.

Solution. (a) Let B1 = A1 and, for n ≥ 2, Bn = An ∩ Acn−1. The events Bn are

disjoint, ∪nk=1Bk = An, and ∪∞k=1Bk = A. We have, by the additivity axiom,

P(A) =

∞∑

k=1

P(Bk) = limn→∞

n∑

k=1

P(Bk) = limn→∞

P(∪nk=1Bk) = lim

n→∞P(An).

(b) Let Cn = Acn and C = Ac. Since An+1 ⊂ An, we obtain Cn ⊂ Cn+1, and the events

Cn are increasing. Furthermore, C = Ac = (∩∞n=1An)c = ∪∞n=1Acn = ∪∞n=1Cn. Using

the result from part (a) for the sequence Cn, we obtain

1−P(A) = P(Ac) = P(C) = lim

n→∞P(Cn) = lim

n→∞(1−P(An)),

from which we conclude that P(A) = limn→∞ P(An).

(c) For the first equality, use the result from part (a) with An = [0, n] and A = [0,∞).For the second, use the result from part (b) with An = [n,∞) and A = ∩∞n=1An = Ø.

SECTION 1.3. Conditional Probability

Problem 8. We roll two fair 6-sided dice. Each one of the 36 possible outcomes isassumed to be equally likely.

(a) Find the probability that doubles were rolled.

(b) Given that the roll resulted in a sum of 4 or less, find the conditional probabilitythat doubles were rolled.

(c) Find the probability that at least one die is a 6.

(d) Given that the two dice land on different numbers, find the conditional probabilitythat at least one die is a 6.

Solution. (a) There are 6 possible outcomes that are doubles, so the probability ofdoubles is 6/36 = 1/6.

(b) The conditioning event (sum is 4 or less) consists of the 6 outcomes

(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (3, 1)

,

2 of which are doubles, so the conditional probability of doubles is 2/6 = 1/3.

(c) There are 11 possible outcomes with at least one 6, namely, (6, 6), (6, i), and (i, 6),for i = 1, 2, . . . , 5. The probability that at least one die is a 6 is 11/36.

(d) There are 30 possible outcomes where the dice land on different numbers. Out ofthese, there are 10 outcomes in which at least one of the rolls is a 6. Thus, the desiredconditional probability is 10/30 = 1/3.

Page 53: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 53

Problem 9. A coin is tossed twice. Alice claims that the event of two heads isat least as likely if we know that the first toss is a head than if we know that at leastone of the tosses is a head. Is she right? Does it make a difference if the coin is fair orunfair? How can we generalize Alice’s reasoning?

Solution. Let A be the event that the first toss is a head and let B be the event thatthe second toss is a head. We must compare the conditional probabilities P(A ∩B |A)and P(A ∩B |A ∪B). We have

P(A ∩ B |A) =P

((A ∩ B) ∩ A

)

P(A)=

P(A ∩ B)

P(A),

and

P(A ∩ B |A ∪ B) =P

((A ∩ B) ∩ (A ∪ B)

)

P(A ∪ B)=

P(A ∩ B)

P(A ∪ B).

Since P(A ∪ B) ≥ P(A), the first conditional probability above is at least as large, soAlice is right, regardless of whether the coin is fair or not. In the case where the coinis fair, that is, if all four outcomes HH , HT , TH , TT are equally likely, we have

P(A ∩ B)

P(A)=

1/4

1/2=

1

2,

P(A ∩ B)

P(A ∪ B)=

1/4

3/4=

1

3.

A generalization of Alice’s reasoning is that if A, B, and C are events such thatB ⊂ C and A ∩ B = A ∩ C (for example, if A ⊂ B ⊂ C), then the event A is morelikely if we know that B has occurred than if we know that C has occurred.

Problem 10. You are given three coins: one has heads in both faces, the second hastails in both faces, and the third has a head in one face and a tail in the other. Youchoose a coin at random, toss it, and it comes heads. What is the probability that theopposite face is tails?

Solution. In this problem, there is a tendency to reason that since the opposite face iseither heads or tails, the desired probability is 1/2. This is, however, wrong, becausegiven that heads came, it is more likely that the two-headed coin was chosen. Thecorrect reasoning is to calculate the conditional probability

P = P(two-headed coin was chosen |heads came)

We have

P(two-headed coin was chosen and heads came) =1

3

P(heads came) =1

2

so by taking the ratio of the above two probabilities, we obtain P = 2/3. Thus theprobability that the opposite face is tails is 1 − P = 1/3.

Problem 11. Monty Hall problem. You are told that a prize is equally likely tobe found behind one out of three closed doors. You point to one of the doors. Then,your friend opens for you one of the remaining two doors, after she makes sure thatthe prize is not behind it. At this point, you can stick to your initial choice, or switch

Page 54: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

54 Sample Space and Probability Chap. 1

to the other unopened door. You win the prize if it lies behind your final choice of adoor.

(a) As far as the probability of winning is concerned, is there an advantage in switch-ing doors? State precisely any modeling assumptions you are making.

(b) Consider the following strategy. You first point to door 1. If door 2 is opened,you do not switch. If door 3 is opened, you switch. What is the probability ofwinning under this strategy?

Solution. (a) Under the strategy of no switching, your initial choice will determinewhether you win or not, and the probability of winning is 1/3. This is because theprize is equally likely to be behind each door, and we are assuming that you are givenno additional information.

Let us now consider the strategy of switching. If the prize is behind the initiallychosen door (probability 1/3), you do not win. If it is not (probability 2/3), and giventhat another door without a prize has been opened for you, you will get to the winningdoor once you switch. Thus, the probability of winning is now 2/3, and this is a betterstrategy.

(b) Under this strategy, there is insufficient information for determining the prob-ability of winning. The answer depends on the way that your friend chooses which doorto open. Let us consider two possibilities.

Suppose that if the prize is behind door 1, your friend always chooses to opendoor 2. (If the prize is behind door 2 or 3, your friend has no choice.) If the prize isbehind door 1, your friend opens door 2, you do not switch and you win. If the prizeis behind door 2, your friend opens door 3, you switch, and you win. If the prize isbehind door 3, your friend opens door 2, you do not switch, and you lose. Thus, theprobability of winning is 2/3.

Suppose now that if the prize is behind door 1, your friend is equally likely toopen either door 2 or 3. If the prize is behind door 1 (probability 1/3), and if yourfriend opens door 2 (probability 1/2), you do not switch and you win (probability 1/6).But if your friend opens door 3, you switch and you lose. If the prize is behind door2, your friend opens door 3, you switch, and you win (probability 1/3). If the prize isbehind door 3, your friend opens door 2, you do not switch and you lose. Thus, theprobability of winning is 1

6+ 1

3= 1

2.

Problem 12. * Show that P(A ∩B |B) = P(A |B), assuming that P(B) > 0.

Solution. Using the definition of conditional probabilities, we have

P(A ∩ B |B) =P(A ∩ B ∩B)

P(B)=

P(A ∩ B)

P(B)= P(A |B).

SECTION 1.4. Total Probability Theorem and Bayes’ Rule

Problem 13. Testing for a rare disease. A test for a certain rare disease has90% accuracy: if a person has the disease, the test results are positive with probability0.9, and if the person does not have the disease, the test results are negative withprobability 0.9. A random person drawn from a certain population has probability0.001 of having the disease. Given that the person just tested positive, what is theprobability of having the disease?

Page 55: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 55

Solution. Let A be the event that the person has the disease. Let B be the event thatthe test results are positive. The desired probability, P(A |B), is found by Bayes’ rule:

P(A |B) =P(A)P(B |A)

P(A)P(B |A) + P(Ac)P(B |Ac)=

0.001 · 0.90

0.001 · 0.90 + 0.999 · 0.10= 0.089.

Note that even though the test was assumed to be fairly accurate, a person who hastested positive is still very unlikely to have the disease.

Problem 14. You have n drawers in your filing cabinet, and you left your termpaper in drawer k with probability pk > 0. The drawers are so messy that even if youcorrectly guess that the term paper is in drawer j, the probability that you find it isonly dj . You search for your paper in a particular drawer, say drawer i, but the searchis unsuccessful. Conditional on this event, show that the probability that your paperis in drawer j, is given by

pj

1 − pidi, if j 6= i,

pi(1− di)

1− pidi, if j = i.

Solution. Let i be the drawer that you search, and let A be the event that you findnothing. Since the paper is in drawer i with probability pi, and your search is successfulwith probability di, the multiplication rule yields P(Ac) = pidi and P(A) = 1 − pidi.Let B be the event that the paper is in drawer j. If j 6= i, then A∩B = B, P(A∩B) =P(B), and we have

P(B |A) =P(A ∩ B)

P(A)=

P(B)

P(A)=

pj

1− pidi,

as required.Consider now the case i = j. Defining the events A and B as above, we obtain

P(B |A) =P(A ∩ B)

P(A)=

P(B)P(A |B)

P(A)=

pi(1− di)

1 − pidi.

Problem 15. How an inferior player with a superior strategy can gainan advantage. Boris is about to play a two-game chess match with an opponent, andwants to find the strategy that maximizes his winning chances. Each game ends witheither a win by one of the players, or a draw. If the score is tied at the end of the twogames, the match goes into sudden-death mode, and the players continue to play untilthe first time one of them wins a game (and the match). Boris has two playing stylesand he can choose one of the two at will in each game, no matter what style he chosein previous games. (1) Timid play with which he draws with probability pd > 0, andhe loses with probability 1− pd. (2) Bold play with which he wins with probability pw,and he loses with probability 1− pw. Boris will always play bold during sudden death,but may switch style between games 1 and 2.

(a) Find the probability that Boris wins the match for each of the following strategies:(i) Play bold in both games 1 and 2.(ii) Play timid in both games 1 and 2.

Page 56: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

56 Sample Space and Probability Chap. 1

Timid Play

1 - pd

pd

Bold Play

0 - 0

1 - 0

0 - 1

1 - pw

pw

1.5-0.5

1 - 1

1 - 1

0 - 2

1 - pw

pwBold Play

Bold Play

Bold Play

0 - 0

1 - 0

0 - 1

1 - pw

pw

1 - 1

1 - 1

0 - 2

1 - pw

pwBold Play

1 - pw

pw

Timid Play

1 - pd

pd

Timid Play

0 - 0

0.5- 1.5

0 - 1

0.5-0.5

0 - 2

Timid Play1 - pd

pd

1 - pd

pd

1 - 1

0.5- 1.5

(a) (b)

(c)

2 - 0

Figure 1.17: Sequential descriptions of the sample space of the chess matchhistories under strategies (i), (ii), and (iii).

(iii) Play timid whenever he is ahead in the score, and play bold otherwise.

(b) Assume that pw < 1/2, so Boris is the worse player, regardless of the playingstyle he adopts. Show that with the strategy in (iii) above, and depending onthe values of pw and pd, Boris may have a better than a 50-50 chance to win thematch. How do you explain this advantage?

Solution. (a) Figure 1.17 provides a sequential description of the sample space for thethree different strategies. Here we assume 1 point for a win, 0 for a loss, and 1/2 pointfor a draw. In the case of a tied 1-1 score, we go to sudden death in the next game, andBoris wins the match with probability pw, or loses the match with probability 1− pw.

(i) Using the total probability theorem and the sequential description of Fig. 1.17(a),

Page 57: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 57

we have

P(Boris wins) = p2w + 2pw(1− pw)pw.

The term p2w corresponds to the win-win outcome, and the term 2pw(1− pw)pw corre-

sponds to the win-lose-win and the lose-win-win outcomes.

(ii) Using Fig. 1.17(b), we have

P(Boris wins) = p2dpw,

corresponding to the draw-draw-win outcome.

(iii) Using Fig. 1.17(c), we have

P(Boris wins) = pwpd + pw(1− pd)pw + (1− pw)p2w.

The term pwpd corresponds to the win-draw outcome, the term pw(1 − pd)pw corre-sponds to the win-lose-win outcome, and the term (1− pw)p2

w corresponds to lose-win-win outcome.

(b) If pw < 1/2, Boris has a greater probability of losing rather than winning any onegame, regardless of the type of play he uses. Despite this, the probability of winningthe match with strategy (iii) can be greater than 1/2, provided that pw is close enoughto 1/2 and pd is close enough to 1. As an example, if pw = 0.45 and pd = 0.9, withstrategy (iii) we have

P(Boris wins) = 0.45 · 0.9 + 0.452 · (1− 0.9) + (1− 0.45) · 0.452 ≈ 0.54.

With strategies (i) and (ii), the corresponding probabilities of a win can be calculatedto be approximately 0.43 and 0.36, respectively. What is happening here is that withstrategy (iii), Boris is allowed to select a playing style after seeing the result of the firstgame, while his opponent is not. Thus, by being able to dictate the playing style ineach game after receiving partial information about the match’s outcome, Boris gainsan advantage.

Problem 16. * Two players take turns removing a ball from a jar that initiallycontains m white and n black balls. The first player to remove a white ball wins.

(a) Derive a recursion for the probability P (m, n) that the starting player wins.

(b) Fix n and let m increase. Use the recursion to show that P (m,n) approaches 1as m → ∞.

(c) Fix m and let n increase. Use the recursion to show that P (m, n) approaches1/2 as n →∞.

Solution. (a) We have, using the total probability theorem,

P (m,n) =m

m + n+

n

m + n

(1 − P (m, n− 1)

)= 1 − n

m + nP (m, n− 1).

The probabilities P (m, 1), P (m, 2), . . . can be calculated using this formula, startingwith the initial condition P (m,0) = 1.

Page 58: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

58 Sample Space and Probability Chap. 1

(b) From the recursion, we see that P (m, n) is greater or equal to m/(m + n), whichapproaches 1 as m →∞.

(c) For fixed m, define

ξn = P (m, n) − 1

2.

Then the recursion of part (a) becomes

ξn = −ξn−1 +m

m + n,

from which

ξn = ξn−2 +m

m + n− m

m + n− 1= ξn−2 −

m

(m + n)(m + n− 1).

Therefore the sequence ξ2k , k = 0, 1, . . . is monotonically decreasing with k, and sincefrom the definition of ξk, it is bounded from below, it must converge to some number.From the above equation, we see that the only possible limit of ξ2k is 0. From thisand the equation ξn = −ξn−1 + m/(m + n), we see that ξ2k−1 also converges to 0 ask → ∞. Therefore the entire sequence ξn converges to 1/2, or equivalently P (m, n)tends to 1/2 as n →∞.

Problem 17. * Each of k jars contains m white and n black balls. A ball is randomlychosen from jar 1 and transferred to jar 2, then a ball is randomly chosen from jar 2and transferred to jar 3, etc. Finally, a ball is randomly chosen from jar k. Show thatthe probability that the last ball is white is the same as the probability that the firstball is white, i.e., it is m/(m + n).

Solution. We derive a recursion for the probability pi that a white ball is chosen in theith jar. We have, using the total probability theorem,

pi+1 =m + 1

m + n + 1pi +

m

m + n + 1(1− pi) =

1

m + n + 1pi +

m

m + n + 1,

starting with the initial condition p1 = m/(m + n). Thus, we have

p2 =1

m + n + 1

m

m + n+

m

m + n + 1=

m

m + n.

More generally, this calculation shows that if pi−1 = m/(m+n), then pi = m/(m+n).Thus, we obtain pi = m/(m + n) for all i.

Problem 18. * We have two jars each containing initially n balls. We perform foursuccessive ball exchanges. In each exchange, we pick simultaneously and at random aball from each jar and move it to the other jar. What is the probability that at theend of the four exchanges all the balls will be in the jar where they started?

Solution. Let pi,n−i(k) denote the probability that after k exchanges, a jar will containi balls that started in that jar and n − i balls that started in the other jar. We wantto find pn,0(4). We argue recursively, using the total probability theorem. We have

pn,0(4) =1

n· 1

n· pn−1,1(3),

Page 59: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 59

pn−1,1(3) = pn,0(2) + 2 · n− 1

n· 1

n· pn−1,1(2) +

2

n· 2

n· pn−2,2(2),

pn,0(2) =1

n· 1

n· pn−1,1(1),

pn−1,1(2) = 2 · n− 1

n· 1

n· pn−1,1(1)

pn−2,2(2) =n− 1

n· n− 1

n· pn−1,1(1),

pn−1,1(1) = 1.

Combining these equations, we obtain

pn,0(4) =1

n2

(1

n2+

4(n − 1)2

n4+

4(n − 1)2

n4

)=

1

n2

(1

n2+

8(n− 1)2

n4

).

Problem 19. * Conditional version of the total probability theorem. Showthe identity

P(A |B) = P(C |B)P(A |B ∩C) + P(Cc |B)P(A |B ∩ Cc),

assuming all the conditioning events have positive probability.

Solution. Using the conditional probability definition and the additivity axiom on thedisjoint sets A ∩ B ∩C and A ∩ B ∩ Cc, we obtain

P(C |B)P(A |B ∩ C) + P(Cc |B)P(A |B ∩Cc)

=P(B ∩ C)

P(B)· P(A ∩B ∩ C)

P(B ∩ C)+

P(B ∩ Cc)

P(B)· P(A ∩ B ∩ Cc)

P(B ∩ Cc)

=P(A ∩ B ∩ C) + P(A ∩ B ∩ Cc)

P(B)

=P

((A ∩B ∩ C) ∪ (A ∩ B ∩ Cc)

)

P(B)

=P(A ∩ B)

P(B)

= P(A |B).

Problem 20. * Let A and B be events with P(A) > 0 and P(B) > 0. We say thatan event B suggests an event A if P(A |B) > P(A), and does not suggest event A ifP(A |B) < P(A).

(a) Show that B suggests A if and only if A suggests B.

(b) Show that B suggests A if and only if Bc does not suggest A. Assume thatP(Bc) > 0.

(c) We know that a treasure is located in one of two places, with probabilities β and1−β, respectively, where 0 < β < 1. We search the first place and if the treasure

Page 60: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

60 Sample Space and Probability Chap. 1

is there, we find it with probability p > 0. Show that the event of not finding thetreasure in the first place suggests that the treasure is in the second place.

Solution. (a) We have P(A |B) = P(A ∩ B)/P(B), so B suggests A if and only ifP(A ∩ B) > P(A)P(B), which is equivalent to A suggesting B, by symmetry.

(b) Arguing as in (a) above, we have that Bc does not suggest A if and only if

P(A ∩ Bc) < P(A)P(B

c).

We haveP(A ∩Bc) = P(A)−P(A ∩ B), P(Bc) = 1 −P(B).

Substituting in the previous inequality, we see that Bc does not suggest A if and onlyif

P(A) −P(A ∩B) < P(A)(1 −P(B)

),

or P(A ∩ B) > P(A)P(B). By part (a), this is equivalent to B suggesting A.

(b) Since P(B) + P(Bc) = 1, we have

P(B)P(A) + P(Bc)P(A) = P(A) = P(B)P(A |B) + P(B

c)P(A |Bc

),

which implies that

P(B)(P(A |B) −P(A)

)= P(B

c)(P(A) −P(A |Bc

)).

Thus, P(A |B) > P(A) (B suggests A) if and only if P(A) > P(A |Bc) (Bc does notsuggest A).

(c) Let A and B be the events

A = the treasure is in the second place,B = we don’t find the treasure in the first place.

Using the total probability theorem, we have

P(B) = P(Ac)P(B |Ac) + P(A)P(B |A) = β(1− p) + (1− β),

so

P(A |B) =P(A ∩ B)

P(B)=

1 − β

β(1− p) + (1− β)=

1− β

1− βp> 1 − β = P(A).

It follows that event B suggests event A.

Problem 21. * The paradox of induction. Consider a statement whose truthis unknown. If we see many examples that are compatible with it, we are tempted toview the statement as more probable. Such reasoning is often referred to as induc-tive inference (in a philosophical, rather than mathematical sense). Consider now thestatement that “all cows are white.” An equivalent statement is that “everything thatis not white is not a cow.” We then observe several black crows. Our observations areclearly compatible with the statement, but do they make the hypothesis “all cows arewhite” more likely?

Page 61: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 61

To analyze this situation, we consider a probabilistic model. Let us assume thatthere are two possible states of the world, which we model as complementary events:

A : all cows are white,

Ac

: 50% of all cows are white.

Let p be the prior probability P(A) that all cows are white. We make an observationof a cow or a crow, with probability q and 1−q, respectively, independently of whetherevent A occurs or not. Assume that 0 < p < 1, 0 < q < 1, and that all crows are black.

(a) Given the event B = a black crow was observed, what is P(A |B)?

(b) Given the event C = a white cow was observed, what is P(A |C)?

Solution. (a) We use the formula

P(A |B) =P(A ∩ B)

P(B)=

P(A)P(B |A)

P(B).

Since all crows are black, we have P(B) = 1 − q. Furthermore, P(A) = p. Finally,P(B |A) = 1 − q = P(B), since the probability of observing a (black) crow is notaffected by the truth of our hypothesis. We conclude that P(A |B) = P(A) = p. Thus,the new evidence, while compatible with the hypothesis “all cows are white,” does notchange our beliefs about its truth.

(b) Once more,

P(A |C) =P(A ∩ C)

P(C)=

P(A)P(C |A)

P(C).

Given the event A, a cow is observed with probability q, and it must be white. Thus,P(C |A) = q. Giben the event Ac, a cow is observed with probability q, and it is whitewith probability 1/2. Thus, P(C |Ac) = q/2. Using the total probability theorem,

P(C) = P(A)P(C |A) + P(Ac)P(C |Ac) = pq + (1− p)q

2.

Hence,

P(A |C) =pq

pq + (1− p)q

2

=2p

1 + p> p.

Thus, the observation of a white cow makes the hypothesis “all cows are white” morelikely to be true.

SECTION 1.5. Independence

Problem 22. A hunter has two hunting dogs. One day, on the trail of some animal,the hunter comes to a place where the road diverges into two paths. He knows thateach dog, independently of the other, will choose the correct path with probability p.The hunter decides to let each dog choose a path, and if they agree, take that one, andif they disagree, to randomly pick a path. Is his strategy better than just letting oneof the two dogs decide on a path?

Page 62: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

62 Sample Space and Probability Chap. 1

Solution. Consider the sample space for the hunter’s strategy. The outcomes that leadto the correct path are:

(1) Both dogs agree on the correct path (probability p2, by independence).

(2) The dogs disagree, dog 1 chooses right path, and hunter follows dog 1 [probabilityp(1− p)/2].

(3) The dogs disagree, dog 2 chooses right path, and hunter follows dog 2 [probabilityp(1− p)/2].

The above events are mutually exclusive, so we can add the probabilities to find thatunder the hunter’s strategy, the probability that he chooses the correct path is

p2 +1

2p(1− p) +

1

2p(1− p) = p.

On the other hand, if the hunter lets one dog choose the path, this dog will also choosethe correct path with probability p. Thus, the two strategies are equally effective.

Problem 23. Communication through a noisy channel. A binary (0 or 1)message transmitted through a noisy communication channel is received incorrectlywith probability ε0 and ε1, respectively (see Fig. 1.18). Errors in different symboltransmissions are independent.

ε0

ε1

1- ε1

1- ε0

1 1

0 0

Figure 1.18: Error probabilities in a binary communication channel.

(a) Suppose that the channel source transmits a 0 with probability p and transmits a1 with probability 1−p. What is the probability that a randomly chosen symbolis received correctly?

(b) Suppose that the string of symbols 1011 is transmitted. What is the probabilitythat all the symbols in the string are received correctly?

(c) In an effort to improve reliability, each symbol is transmitted three times andthe received symbol is decoded by majority rule. In other words, a 0 (or 1) istransmitted as 000 (or 111, respectively), and it is decoded at the receiver as a0 (or 1) if and only if the received three-symbol string contains at least two 0s(or 1s, respectively). What is the probability that a transmitted 0 is correctlydecoded?

(d) Suppose that the channel source transmits a 0 with probability p and transmitsa 1 with probability 1 − p, and that the scheme of part (c) is used. What is theprobability that a 0 was transmitted given that the received string is 101?

Page 63: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 63

Solution. (a) Let A be the event that a 0 is transmitted. Using the total probabilitytheorem, the desired probability is

P(A)(1 − ε0) +(1−P(A)

)(1− ε1) = p(1− ε0) + (1− p)(1− ε1).

(b) By independence, the probability that the string 1011 is received correctly is

(1− ε0)(1− ε1)3.

(c) In order for a 0 to be decoded correctly, the received string must be 000, 001, 010,or 100. Given that the string transmitted was 000, the probability of receiving 000 is(1 − ε0)

3, and the probability of each of the strings 001, 010, and 100 is ε0(1 − ε0)2.

Thus, the probability of correct decoding is

3ε0(1− ε0)2 + (1− ε0)

3.

(d) Using Bayes’ rule, we have

P(0 | 101) =P(0)P(101 | 0)

P(0)P(101 | 0) + P(1)P(101 | 1) .

The probabilities needed in the above formula are

P(0) = p, P(1) = 1 − p, P(101 | 0) = ε20(1− ε0), P(101 | 1) = ε1(1− ε1)

2.

Problem 24. An electrical system consists of identical components that withprobability p independently of other components. The components are connected asshown in Fig. 1.19. The system succeeds if there is a path that starts at point A, endsat point B, and consists of successful components. What is the probability of success?

A B1

2

3

Figure 1.19: A system of identical components, which succeeds if there is a paththat starts at point A, ends at point B, and consists of successful components.

Solution. The system may be viewed as a series connection of three subsystems, denoted1, 2, and 3 in Fig. 1.19. The probability of success of the entire system is p1p2p3, where

Page 64: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

64 Sample Space and Probability Chap. 1

pi is the probability of success of subsystem i. Using the formulas for the probabilityof success of a series or a parallel system given in Example 1.22, we have

p1 = p, p3 = 1 − (1− p)2,

andp2 = 1 − (1− p)

(1− p

(1 − (1− p)

3))

.

Problem 25. Reliability of a k-out-of-n system. A system consists of n identicalcomponents that are reliable with probability p independently of other components.The system succeeds if at least k out of the n components work reliably. What is theprobability of success?

Solution. Let Ai be the event that exactly i components work reliably. The probabilityof success is the union ∪n

i=kAi, and since the Ai are disjoint, it is equal to

n∑

i=k

P(Ai) =

n∑

i=k

p(i),

where p(i) are the binomial probabilities. Thus, the probability of success is

n∑

i=k

(n

i

)pi(1− p)n−i.

Problem 26. A cellular phone system services a population of n1 “voice users”(those that occasionally need a voice connection) and n2 “data users” (those thatoccasionally need a data connection). We estimate that at a given time, each user willneed to be connected to the system with probability p1 (for voice users) or p2 (for datausers), independently of other users. The data rate for a voice user is r1 bits/sec andfor a data user is r2 bits/sec. The cellular system has a total capacity of c bits/sec.What is the probability that more users want to use the system than the system canaccommodate?

Solution. The probability that k1 voice users and k2 data users simultaneously needthe facility is p1(k1)p2(k2), where p1(k1) and p2(k2) are the corresponding binomialprobabilities, given by

pi(ki) =

(n

ki

)p

kii (1− pi)

n−ki , i = 1, 2.

The probability that more users want to use the system than the system canaccommodate is the sum of all products p1(k1)p2(k2) as k1 and k2 range over all possiblevalues whose total bit rate requirement k1r1+k2r2 exceeds the capacity c of the system.Thus, the desired probability is

(k1,k2) | k1r1+k2r2>c, k1≤n1, k2≤n2

p1(k1)p2(k2).

Page 65: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 65

Problem 27. Imagine a drunk tightrope walker, who manages to keep his balance,and takes a forward step with probability p, or backward step with probability (1− p),independently of what he did in previous steps.

(a) What is the probability that after two steps the tightrope walker will be at thesame place on the rope?

(b) What is the probability that after three steps, he will be one step forward fromwhere he began?

(c) Given that after three steps he has managed to move ahead one step, what is theprobability that the first step he took was a step forward?

Solution. (a) In order to end up in the same place after two steps, the tightrope walkercan make a forward step followed by a backward step, or vice versa. Therefore therequired probability is 2p(1− p).

(b) The probability that after three steps he will be one step ahead of his starting pointis the probability that there are exactly two forward steps out of a total of three steps.This corresponds to the event

A =(F,F,B), (F, B, F ), (B, F, F )

where F and B stand for a forward or backward step, respectively. Each of the possibleoutcomes has probability p2(1− p), so

P(A) = 3p2(1− p).

(c) The conditioning event is the event A above. Two out of the three outcomes in Astart with a forward step. Therefore, the desired conditional probability is 2/3.

Problem 28. A power utility can supply electricity to a city from n different powerplants. All n work quite efficiently together, but in fact any one by itself can produceenough electricity to supply the entire city. Now suppose that each one of these powerplants fails independently of the others, and power plant i fails with probability pi.

(a) What is the probability that the city will experience a black-out?

(b) Now suppose that the city increases its demand for electricity, so that two powerplants are necessary to keep the city from a black-out. Find the probability thatthe city will experience a black-out.

Solution. (a) Let A denote the event that the city experiences a black-out. Since thepower plants fail independently of each other, we know that

P(A) =

n∏

i=1

pi.

(b) If two power plants are necessary to keep the city from a black out, the city willblack out if either all n or any n− 1 power plants fail. These two events are mutuallyexclusive, so we can calculate the probability P(A) of a black-out by adding theirprobabilities:

P(A) =

n∏

i=1

pi +

n∑

i=1

((1− pi)

j 6=i

pj

).

Page 66: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

66 Sample Space and Probability Chap. 1

Here, (1− pi)∏

j 6=ipj is the probability that n− 1 plants have failed and plant i is the

one that has not failed.

Problem 29. Independence/pairwise independence example. Ina Rush isdisappointed because she never gets all of the three traffic lights on her way to workto be green. Yet Ina is convinced that the three lights are independently red or green.Can Ina be right? If Ina is wrong, is it possible that the light colors she encounters arepairwise independent?

Solution. Let F , S, and T be the events that the first, second, and third lights aregreen, respectively. We know that P(F ∩S ∩ T ) = 0. If F , S, and T are independent,we must have P(F ∩S ∩T ) = P(F )P(S)P(T ), so it follows that one of the three lightsmust always be red when Ina gets to it [P(F ) = 0 or P(S) = 0 or P(T ) = 0]. Thismay be possible. In particular, suppose that the first two lights stay green or red for1 minute intervals, Ina takes half a minute to reach the second light from the first,and the second light becomes red half a minute after the first becomes green. For anexample of a probability law under which the second light is always red but the threelights are independent, suppose that the light sequences where the second light is red,

(R,R,R), (G,R,G), (R,R,G), (G,R,R),

all have probability 1/4.Suppose that all the light sequences that Ina encounters involve either one or

three red lights, and all these sequences are equally likely, i.e,

P(R,R,R) = P(R,G,G) = P(G,R,G) = P(G,G,R) =1

4.

Then it can be seen that F , S, and T have probability 1/2, and that the events F ∩S,F ∩T , S∩T have probabilities 1/4, so F , S, and T are pairwise independent. However,F , S, and T are not independent, since P(F ∩ S ∩ T ) = 0 6= 1/8 = P(F )P(S)P(T ).

Problem 30. A company is interviewing potential employees. Suppose that eachcandidate is either qualified, or unqualified with given probabilities q and 1 − q, re-spectively. The company tries to determine this by asking 20 true or false questions.A candidate gets a C for each correct answer, and an I for each incorrect answer.A qualified candidate has probability p of answering the question correctly, while anunqualified candidate has a probability p of answering incorrectly. The answers to dif-ferent questions are assumed to be independent. If the company considers anyone withat least 15 C’s qualified, and everyone else unqualified, what is the probability that the20 questions will correctly identify someone to be qualified or unqualified?

Solution. Let Q be the event that someone is qualified, Qc the event that someone isunqualified, and A the event that the 20 questions correctly determine whether thecandidate is qualified or not. Using the total probability theorem, we have

P(A) = P(A ∩Q) + P(A ∩Qc)

= P(Q) ·P(A |Q) + P(Qc) · P(A |Qc)

= q

20∑

i=15

(20

i

)pi(1− p)20−i + (1− q)

20∑

i=6

(20

i

)pi(1− p)20−i.

Page 67: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 67

Problem 31. The problem of points. Telis and Wendy play a round of golf(18 holes) for a $10 stake, and their probabilities of winning on any one hole are pand 1 − p, respectively, independently of their results in other holes. At the end of 10holes, with the score 4 to 6 in favor of Wendy, Telis receives an urgent call and has toreport back to work. They decide to split the stake in proportion to their probabilitiesof winning had they completed the round, as follows. If pT and pW are the conditionalprobabilities that Telis and Wendy, respectively, are ahead in the score after 18 holesgiven the 4-6 score after 10 holes, then Telis should get a fraction pT /(pT + pW ) of thestake, and Wendy should get the remaining pW /(pT + pW ). How much money shouldTelis get? Note: This is an example of the, so-called, problem of points, which playedan important historical role in the development of probability theory. The problemwas posed by Chevalier de Mere in the 17th century to Pascal, who introduced theidea that the stake of an interrupted game should be divided in proportion to theplayers’ conditional probabilities of winning given the state of the game at the time ofinterruption. Pascal worked out some special cases and through a correspondence withFermat, stimulated much thinking and several probability-related investigations.

Solution. We have

pT = P(at least 6 out of the 8 remaining holes are won by Telis),

pW = P(at least 4 out of the 8 remaining holes are won by Wendy).

Using the binomial formulas,

pT =

8∑

k=6

(8

k

)pk(1− p)8−k pW =

8∑

k=4

(8

k

)(1− p)kp8−k.

The amount of money that Telis should get is 10pT /(pT + pW ) dollars.

Problem 32. * Gambler’s ruin. Two gamblers, G1 and G2, hold a sequence ofindependent betting rounds. In each round, G1 wins with probability p, and G2 winswith probability q = 1 − p. The winner of a round collects $1 from the loser. Initially,G1 has k dollars, and G2 has N − k dollars, and play continues until one of them hasno money left. What is the probability that G1 wins?

Solution. Let us denote by Pk the probability that G1 wins all the money given thathe starts with k and G2 starts with N − k. Let us also denote by A the event thatthis happens, and by F the event that G1 wins the first round. We apply the totalprobability theorem to obtain

Pk = P(A |F )P(F ) + P(A |F c)P(F c)

= pP(A |F ) + qP(A |F c).

By the independence of past and future events, P(A |F ) = Pk+1 and similarly P(A |F c) =Pk−1. Thus, we have pPk + qPk = pPk+1 + qPk−1 for all k, or

Pk+1 − Pk = r(Pk − Pk−1),

Page 68: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

68 Sample Space and Probability Chap. 1

where r = q/p. We will solve for Pk in terms of p and q using iteration and theboundary values P0 = 0 and PN = 1. Since P0 = 0, we obtain

Pk =

P1

1− rk

1− r, if p 6= q,

kP1, if p = q.

Since PN = 1, we can solve for P1 and therefore for Pk:

P1 =

1 − r

1− rN, if p 6= q,

1

N, if p = q,

so that

Pk =

1 − rk

1 − rN, if p 6= q,

k

N, if p = q.

Problem 33. * Consider a biased coin that comes up heads with probability p andtails with probability 1− p. Let qn be the probability that after n independent tosses,there have been an even number of heads.

(a) Show that qn = p(1− qn−1) + (1− p)qn−1.

(b) Show that qn =(1 + (1− 2p)n

)/2.

Solution. (a) Let A be the event that the first n − 1 tosses produce an even numberof heads, and let E be the event that the nth toss is a head. We can obtain an evennumber of heads in n tosses in two distinct ways: 1) there is an even number of headsin the first n − 1 tosses, and the nth toss results in tails: this is the event A ∩ Ec; 2)there is an odd number of heads in the first n − 1 tosses, and the nth toss results inheads: this is the event Ac ∩ E. Using also the independence of A and E,

qn = P((A ∩ Ec) ∪ (Ac ∩ E)

)

= P(A ∩Ec) + P(Ac ∩ E)

= P(A)P(Ec) + P(Ac)P(E)

= (1− p)qn−1 + p(1− qn−1).

(b) We will iterate the above expression, and use the property q0 = 1 (with zero tosses,we have zero heads, which is even) to get the desired result:

qn = p(1− qn−1) + (1− p)qn−1

= p + (1− 2p)qn−1

= p + (1− 2p)p + (1− 2p)2qn−2

= · · ·= p

(1 + (1− 2p) + (1− 2p)2 + · · ·+ (1− 2p)n−1

)+ (1− 2p)n.

Page 69: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 69

Assuming that p 6= 0, we can use the identity

1 + (1− 2p) + (1− 2p)2 + (1− 2p)3 + · · ·+ (1− 2p)n−1 =1 − (1− 2p)n

1− (1− 2p).

Therefore,

qn = p(1 + (1− 2p) + (1− 2p)2 + · · ·+ (1− 2p)n−1) + (1− 2p)n

= p1 − (1− 2p)n

1 − (1− 2p)+ (1− 2p)n

=1

2− (1− 2p)n

2+ (1− 2p)n

=1 + (1− 2p)n

2.

For the case p = 0, the number of heads will be zero, which is even, and qn = 1, whichagrees with the desired result.

Problem 34. * A particular class has had a history of low attendance. Fed up withthe situation, the professor decides that she will not lecture unless at least k of the nstudents enrolled in the class are present. Each student will independently show upwith probability pg if the weather is good, and with probability pb if the weather isbad. If the chance of bad weather tomorrow is P(B), what is the probability that theprofessor teaches her class?

Solution. Let the event A be the event that the professor teaches her class. We have

P(A) = P(A ∩ B) + P(A ∩ Bc) = P(B)P(A |B) + P(B

c)P(A |Bc

).

We also have

P(A |B) =

n∑

i=k

(n

i

)· pi

b(1− pb)n−i,

P(A |Bc) =

n∑

i=k

(n

i

)· pi

g(1− pg)n−i.

Therefore,

P(A) = P(B)

n∑

i=k

(n

i

)· pi

b(1− pb)n−i +

(1−P(B)

) n∑

i=k

(n

i

)· pi

g(1− pg)n−i.

Problem 35. * Let A and B be independent events. Use the definition of indepen-dence to prove the following:

(a) A and Bc are independent.

(b) Ac and Bc are independent.

Solution. (a) The event A is the union of the disjoint events A ∩Bc and A ∩B. Usingthe additivity axiom and the independence of A and B, we obtain

P(A) = P(A ∩ B) + P(A ∩ Bc) = P(A)P(B) + P(A ∩ Bc).

Page 70: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

70 Sample Space and Probability Chap. 1

It follows that P(A ∩ Bc) = P(A)(1−P(B)

)= P(A)P(Bc).

(b) Apply the result of part (a) twice: first on A and B, then on Bc and A.

Problem 36. * Suppose that A, B, and C are independent. Use the mathematicaldefinition of independence to show that A and B ∪ C are independent.

Solution. To prove independence, we need to show that P(A ∩ (B ∪ C)

)= P(A) ·

P(B ∪ C). Using the identity A ∩ (B ∪C) = (A ∩ B) ∪ (A ∩ C), we obtain

P(A ∩ (B ∪ C)

)= P

((A ∩ B) ∪ (A ∩ C)

)

= P(A ∩ B) + P(A ∩ C) −P((A ∩ B) ∩ (A ∩ C)

)

= P(A ∩ B) + P(A ∩ C) −P(A ∩ B ∩C).

The independence of A, B, and C implies that P(A ∩ B) = P(A)P(B), P(A ∩ C) =P(A)P(C), and P(A ∩ B ∩C) = P(A)P(B)P(C). It follows that

P(A ∩ (B ∪ C)

)= P(A)P(B) + P(A)P(C) −P(A)P(B)P(C)

= P(A)(P(B) + P(C) −P(B)P(C)

)

= P(A)P(B ∪C).

Problem 37. * Suppose that A, B, and C are independent. Prove formally that Aand B are conditionally independent given C.

Solution. We need to show that P(A ∩ B |C) = P(A |C)P(B ∩C). We have

P(A ∩ B |C) =P(A ∩B ∩ C)

P(C)

=P(A)P(B)P(C)

P(C)

= P(A)P(B)

= P(A |C)P(B |C).

The first equality uses the definition of conditional probabilities; the second uses theassumed independence; the fourth uses the independence of A from C, and of B fromC.

Problem 38. * Assume that the events A1, A2, A3, A4 are independent and thatP(A3 ∩A4) > 0. Show that

P(A1 ∪ A2 |A3 ∩ A4) = P(A1 ∪ A2).

Solution. We have

P(A1 |A3 ∩A4) =P(A1 ∩A3 ∩ A4)

P(A3 ∩ A4)=

P(A1)P(A3)P(A4)

P(A3)P(A4)= P(A1).

Page 71: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 71

One obtains similarly that P(A2 |A3 ∩ A4) = P(A2) and P(A1 ∩ A2 |A3 ∩ A4) =P(A1 ∩A2), and, finally,

P(A1 ∪A2 |A3 ∩A4) = P(A1 |A3 ∩A4) + P(A2 |A3 ∩ A4)

−P(A1 ∩ A2 |A3 ∩ A4)

= P(A1) + P(A2)−P(A1 ∩A2)

= P(A1 ∪ A2).

Problem 39. * Laplace’s rule of succession. Consider N + 1 boxes with the kthbox containing k red balls and N − k white balls, where k ranges from 0 to N . Wechoose a box at random (all boxes are equally likely) and then choose a ball at randomfrom that box, n successive times (the ball drawn is replaced each time, and a new ballis selected independently). Suppose a red ball was drawn each of the n times. Whatis the probability that if we draw a ball one more time it will be red? Estimate thisprobability for large N .

Solution. We want to find the conditional probability P(E |Rn), where E is the eventof a red ball drawn at time n+1, and Rn is the event of a red ball drawn each of the npreceding times. Intuitively, the consistent draw of a red ball indicates that a box witha high percentage of red balls was chosen, so we expect that P(E |Rn) is closer to 1than to 0. In fact, Laplace used this example to calculate the probability that the sunwill rise tomorrow given that it has risen for the preceding 5,000 years (n = 1, 826, 213days). (It is not clear how serious Laplace was about this calculation, but the story ispart of the folklore of probability theory.)

We have

P(E |Rn) =P(E ∩ Rn)

P(Rn),

where using the total probability theorem, we have

P(Rn)=

N∑

k=0

P(kth box chosen)(

k

N

)n

=1

N + 1

N∑

k=0

(k

N

)n

,

P(E ∩ Rn)= P(Rn+1) =1

N + 1

N∑

k=0

(k

N

)n+1

.

For large N , we can view P(Rn) as a piecewise constant approximation to an integral:

P(Rn) =1

N + 1

N∑

k=0

(k

N

)n

≈ 1

(N + 1)Nn

∫ N

0

xndx =

1

(N + 1)Nn· Nn+1

n + 1≈ 1

n + 1.

Similarly,

P(E ∩Rn) = P(Rn+1) ≈1

n + 2,

so that

P(E |Rn) ≈ n + 1

n + 2.

Page 72: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

72 Sample Space and Probability Chap. 1

Thus, for large N , drawing a red ball one more time is almost certain.

Problem 40. * Show the formula for the binomial coefficients

(n

k

)=

n!

k!(n− k)!,

and also the binomial formula by using the, so called, Pascal triangle, given in Fig.1.21.

Solution. Note that n-toss sequences that contain k heads can be obtained in two ways:

(1) By starting with an n− 1-toss sequence that contains k heads and adding a tailat the end. There are

(n−1

k

)different sequences of this type.

(2) By starting with an n − 1-toss sequence that contains k − 1 heads and adding ahead at the end. There are

(n−1k−1

)different sequences of this type.

Thus,

(n

k

)=

(n− 1

k − 1

)+

(n − 1

k

)if k = 1, 2, . . . , n− 1,

1 if k = 0, n.

We now use the above relation to demonstrate the formula

(n

k

)=

n!

k!(n− k)!,

by induction on n. Indeed, we have from the definition(10

)=

(11

)= 1, so for n = 1 the

above formula is seen to hold as long as we use the convention 0! = 1. If the formulaholds for each index up to n − 1, we have for k = 1, 2, . . . , n− 1,

(n

k

)=

(n − 1

k − 1

)+

(n− 1

k

)

=(n− 1)!

(k − 1)!(n− 1 − k + 1)!+

(n− 1)!

k!(n − 1− k)!

=k

n· n!

k!(n− k)!+

n− k

n· n!

k!(n − k)!

=n!

k!(n− k)!,

and the induction is complete. Since the binomial probabilities p(k) =(

nk

)pk(1−p)n−k

must add to 1, we have the binomial formula

n∑

k=0

(n

k

)p

k(1− p)

n−k= 1.

Page 73: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 73

1

2

4

2

3( )0

3( )2

2( )1

1( )

1

3( ) 3

3( )

0

0( )

0

4( ) 1

4( ) 2

4( ) 3

4( ) 4

4( )

1

2( )0

2( )0

1( ) 1 1

. . . . . . . .

4

1 1

1 1

1 1

3

6

3

. . . . . . . .

Figure 1.21: Sequential calculation method of the binomial coefficients using thePascal triangle. Each term

(nk

)in the triangular array on the left is computed

and placed in the triangular array on the right by adding its two neighbors in therow above it (except for the boundary terms with k = 0 or k = n, which are equalto 1).

SECTION 1.6. Counting

Problem 41. The birthday problem. Consider n people who are attending aparty. We assume that every person has an equal probability of being born on any dayduring the year, independently of everyone else, and ignore the additional complicationpresented by leap years (i.e., nobody is born on February 29). What is the probabilitythat each person has a distinct birthday?

Solution. The sample space consists of all possible choices for the birthday of eachperson. Since there are n persons, and each has 365 choices for their birthday, thesample space has 365n elements. Let us now consider those choices of birthdays forwhich no two persons have the same birthday. Assuming that n ≤ 365, there are 365choices for the first person, 364 for the second, etc., for a total of 365 ·364 ·(365−n+1).Thus,

P(no two birthdays coincide) =365 · 364 · (365 − n + 1)

365n.

It is interesting to note that for n as small as 23, the probability that there are twopersons with the same birthday is larger than 1/2.

Problem 42. We draw the top 7 cards from a well-shuffled standard 52-card deck.Find the probability that:

(a) The 7 cards include exactly 3 aces.

(b) The 7 cards include exactly 2 kings.

(c) The probability that the 7 cards include exactly 3 aces or exactly 2 kings or both.

Solution. (a) The sample space consists of all ways of drawing 7 elements out of a52-element set, and its cardinality is

(527

). Let us count those outcomes that involve

exactly 3 aces. We are free to select any 3 out of the 4 aces, and any 4 out of the 48

Page 74: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

74 Sample Space and Probability Chap. 1

remaining cards, for a total of(43

)(484

)choices. Thus,

P(7 cards include exactly 3 aces) =

(4

3

)(48

4

)

(52

7

) .

(b) Proceeding the same way as in part (a), we obtain

P(7 cards include exactly 2 kings) =

(4

2

)(48

5

)

(52

7

) .

(c) If A and B stand for the events in parts (a) and (b), respectively, we are lookingfor P(A∪B) = P(A)+P(B)−P(A∩B). The event A∩B (having exactly 3 aces andexactly 2 kings) can materialize by choosing 3 out of the 4 available aces, 2 out of the4 available kings, and 2 more cards out of the remaining 44. Thus, this event consistsof

(43

)(42

)(442

)distinct outcomes. Hence,

P(7 cards include 3 aces and/or 2 kings) =

(4

3

)(48

4

)+

(4

2

)(48

5

)−

(4

3

)(4

2

)(44

2

)

(52

7

) .

Problem 43. A well-shuffled standard 52-card deck is dealt to 4 players. Find theprobability that each of the players gets an ace.

Solution. The size of the sample space is the number of different ways that 52 objectscan be divided in 4 groups of 13, and is given by the multinomial formula

52!

13!13!13!13!.

There are 4! different ways of distributing the 4 aces to the players, and there are

48!

12!12!12!12!

different ways of dividing the remaining 48 cards into 4 groups of 12. Thus, the desiredprobability is

4!48!

12!12!12!12!52!

13!13!13!13!

.

A second solution can be obtained by considering a different, but probabilisticallyequivalent of dealing the cards. Each player has 13 slots, each one of which is to receive

Page 75: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 75

one card. Instead of shuffling the deck, we place the 4 aces at the top, and start dealingthe cards one at a time, with each free slot being equally likely to receive the next card.For the event of interest to materialize, the first ace can go anywhere; the second cango to any one of the 39 slots (out of the 51 available) that correspond to players that donot yet have an ace; the third can go to any one of the 26 slots (out of the 50 available)that correspond to the two players that do not yet have an ace; and finally, the fourth,can go to any one of the 13 slots (out of the 49 available) that correspond to the onlyplayer who does not yet have an ace. Thus, the desired probability is

39 · 26 · 1351 · 50 · 49 .

By simplifying our previous answer, it can be checked that it is the same as the oneobtained here, thus corroborating the intuitive fact that the two different ways ofdealing the cards are equivalent.

Problem 44. Twenty distinct cars park in the same parking lot every day. Tenof these cars are US-made, while the other ten are foreign-made. The parking lot hasexactly twenty spaces, all in a row, so the cars park side by side. However, the drivershave varying schedules, so the position any car might take on a certain day is random.

(a) In how many different ways can the cars line up?

(b) What is the probability that on a given day, the cars will park in such a waythat they alternate (no two US-made are adjacent and no two foreign-made areadjacent)?

Solution. (a) Since the cars are all distinct, there are 20! ways to line them up.

(b) To find the probability that the cars will be parked so that they alternate, wecount the number of “favorable” outcomes, and divide by the total number of possibleoutcomes found in part (a). We count in the following manner. We first arrange theUS cars in an ordered sequence (permutation). We can do this in 10! ways, since thereare 10 distinct cars. Similarly, arrange the foreign cars in an ordered sequence, whichcan also be done in 10! ways. Finally, interleave the two sequences. This can be donein two different ways, since we can let the first car be either US-made or foreign. Thus,we have a total of 2 · 10! · 10! possibilities, and the desired probability is

2 · 10! · 10!20!

.

Note that we could have solved the second part of the problem by neglecting the factthat the cars are distinct. Suppose the foreign cars are indistinguishable, and also thatthe US cars are indistinguishable. Out of the 20 available spaces, we need to choose10 spaces in which to place the US cars, and thus there are

(2010

)possible outcomes.

Out of these outcomes, there are only two in which the cars alternate, depending onwhether we start with a US or a foreign car. Thus, the desired probability is 2

(2010

),

which coincides with our earlier answer.

Problem 45. We deal from a well-shuffled 52-card deck.

(a) What is the probability that the 13th card dealt is a king?

(b) What is the probability that the 13th card is the first king to be dealt?

Page 76: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

76 Sample Space and Probability Chap. 1

Solution. (a) Since we are given no information on the first 12 cards that are dealt, theprobability that the 13th card dealt is a king is the same as the probability that thefirst card dealt is a king, and equals 4/52.

(b) The probability that the 13th card is the first king to be dealt is the probability thatout of the first 13 cards to be dealt, exactly one was a king, and that the king was dealtlast. Now, given that exactly one king was dealt in the first 13 cards, the probabilitythat the King was dealt last is just 1

13 since each place in line is equally likely. Thus, itremains to calculate the probability that there was exactly one King in the first 13 cardsdealt. To calculate this probability we count the “favorable” outcomes and divide bythe total number of possible outcomes. We first count the favorable outcomes, namelythose with exactly one King in the first 13 cards dealt. We can choose a particularKing in 4 ways, and we can choose the other 12 cards in

(4812

)ways, therefore there are

4 ·(4812

)favorable outcomes. There are

(5213

)total outcomes, so the desired probability

is1

13·4 ·

(4812

)(5213

) .

For an alternative solution, we argue as in Example 1.10. The probability thatthe first card is not a king is 48/52. Given that, the probability that the second isnot a king is 47/51. We continue similarly until the 12th card. The probability thatthe 12th card is not a king, given that none of the preceding 11 was a king is 37/41.(There are 52−11 = 41 cards left, and 48−11 = 37 of them are not kings.) Finally, theconditional probability that the 13th card is a king is 4/40. The desired probability is

48 · 47 · · · 37 · 452 · 51 · · · 41 · 40 .

Problem 46. An urn contains m red and n white balls.

(a) We draw two balls simultaneously and at random. Describe the sample space andcalculate the probability that the selected balls are of different color, by usingtwo approaches: a counting approach based on the discrete uniform law, and asequential approach based on the multiplication rule.

(b) A fair 3-sided die is rolled and if k comes up, where k = 1, 2, 3, we remove kballs from the urn at random and put them aside. Describe the sample spaceand calculate the probability that all of the balls drawn are red, using a divide-and-conquer approach and the total probability theorem.

Solution. (a) Although we pick the balls simultaneously, we can still reason as if weare picking them sequentially. One possible sample space is obtained by numberingthe red balls from 1 to m, the white balls from m + 1 to m + n, and by letting thepossible outcomes be all ordered pairs of integers (i, j) with 1 ≤ i, j ≤ m+n and i 6= j.All outcomes are equally likely, so we can use the counting method. The total numberof possible outcomes is (m + n)(m + n − 1). The number of outcomes correspondingto red-white selection, (i.e., i ∈ 1, . . . ,m and j ∈ m + 1, . . . , m + n) is mn. Thenumber of outcomes corresponding to white-red selection, (i.e., i ∈ m + 1, . . . , n andj ∈ 1, . . . , m) is also mn. Thus, the desired probability that the balls are of differentcolor is

2mn

(m + n)(m + n − 1).

Page 77: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 77

Another possible sample space consists of all the possible ordered color pairs,i.e., RR, RW,WR, WW. We then have to calculate the probability of the eventRW, WR. We consider a sequential description of the experiment, i.e., we first selectthe first ball and then the second. In the first stage, the probability of a red ball ism/(m+n). In the second stage, the probability of a red ball is either m/(m+n−1) or(m− 1)/(m + n− 1) depending on whether the first ball was blue or red, respectively.Therefore, using the multiplication rule, we have

P(RR) =m

m + n· m− 1

m − 1 + n, P(RW ) =

m

m + n· n

m − 1 + n,

P(WR) =n

m + n· m

m + n− 1, P(WW ) =

n

m + n· n − 1

m + n − 1.

The desired probability is

P(RW,WR

)= P(RW ) + P(WR)

=m

m + n· n

m− 1 + n+

n

m + n· m

m + n− 1

=2mn

(m + n)(m + n− 1).

(b) We calculate the conditional probability of all balls being red, given any of thepossible values of k. We have P(R | k = 1) = m/(m + n) and, as found in part (a),P(RR | k = 2) = m(m − 1)/(m + n)(m − 1 + n). Arguing sequentially as in part (a),we also have P(RRR | k = 3) = m(m − 1)(m − 2)/(m + n)(m − 1 + n)(m − 2 + n).According to the total probability theorem, the desired answer is

1

3

(m

m + n+

m(m − 1)

(m + n)(m− 1 + n)+

m(m− 1)(m − 2)

(m + n)(m − 1 + n)(m − 2 + n)

).

Problem 47. Eight rooks are randomly placed in distinct squares of a 8 × 8 chess-board. Find the probability that all the rooks are safe from one another, i.e., that thereis no row or column with more than one rook.

Solution. We count the number of ways in which we can safely place 8 distinguishablerooks, and then divide this by the total number of possibilities. First we count thenumber of favorable positions for the rooks. We will place the rooks one by one on the8 × 8 chessboard. For the first rook, there are no constraints, so we have 64 choices.Placing this rook, however, eliminates one row and one column. Thus, for our secondrook, we can imagine that the illegal column and row have been removed, thus leavingus with a 7 × 7 chessboard, and thus with 49 choices. Similarly, for the third rook wehave 36 choices, for the fourth 25, etc.

In the absence of any restrictions, there are 64 · 63 · · · 57 ways we can place 8rooks, so the desired probability is

64 · 49 · 36 · 25 · 16 · 9 · 464!

56!

.

Page 78: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

78 Sample Space and Probability Chap. 1

Problem 48. De Mere’s Paradox. A six-sided die is rolled three times indepen-dently. Which is more likely: a sum of 11 or a sum of 12? (This question was posedby the French nobleman De Mere to his friend Pascal in the 17th century.)

Solution. A sum of 11 is obtained with the following 6 combinations:

(6, 4, 1) (6, 3, 2) (5, 5, 1) (5, 4, 2) (5, 3, 3) (4, 4, 3).

A sum of 12 is obtained with the following 6 combinations:

(6, 5, 1) (6, 4, 2) (6, 3, 3) (5, 5, 2) (5, 4, 3) (4, 4, 4).

Each combination of 3 distinct numbers corresponds to 6 permutations, while eachcombination of 3 numbers, two of which are equal corresponds to 3 permutations.Counting the number of permutations in the 6 combinations corresponding to a sumof 11, we obtain 6 + 6 + 3 + 6 + 3 + 3 = 27 permutations. Counting the number ofpermutations in the 6 combinations corresponding to a sum of 12, we obtain 6 + 6 +3 + 3 + 6 + 1 = 25 permutations. Since all permutations are equally likely, a sum of 11is more likely than a sum of 12.

Note also that the sample space has 63 = 216 elements, so we have P(11) =27/216, P(12) = 25/216

Problem 49. A club consists of a club leader and a number (possibly zero) ofadditional club members.

(a) Any subset of n given persons may decide to form a club. Explain why thenumber of possible clubs is n2n−1.

(b) Find a different way of counting the number of possible clubs and establish that

n∑

k=1

k

(n

k

)= n2n−1.

Solution. (a) There are n choices for the club leader. Once the leader is chosen, we areleft with a set of n − 1 available persons, and we are free to choose any of the 2n−1

subsets.

(b) We can form a k-person club by first selecting k out of the n available persons(there are

(nk

)choices), and then selecting one of the members to be a leader (there

are k choices). Thus, there is a total of k(

nk

)k-person clubs. We then sum over all k

to obtain the number of possible clubs of any size.

Problem 50. * Correcting the number of permutations for indistinguishableobjects. When permuting n objects some of which are indistinguishable, differentpermutations may lead to the same object sequence, so the number of distinguishableordered sequences is less than n!. For example there are six permutations of the lettersA, B, and C:

ABC, ACB, BAC, BCA, CAB, CBA,

but only three distinguishable permutations of the letters A, D, and D:

ADD, DAD, DDA.

Page 79: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 1.7 Summary and Discussion 79

(a) Suppose that k out of the n objects are indistinguishable. Show that the numberof distinguishable ordered sequences is n!/k!.

(b) Suppose that we have r types of indistinguishable objects, and for each i, ki

objects of type i. Show that the number of distinguishable ordered sequences is

n!

k1! k2! · · · kr !.

Solution. (a) Each one of the n! permutations corresponds to k! duplicates which areobtained by permuting the k indistinguishable objects. Thus, the n! permutations canbe grouped into n!/k! groups of k! indistinguishable permutations each, and the numberof distinguishable ordered sequences is n!/k!. For example the three letters A, D, andD give the 3! = 6 permutations

ADD, ADD, DAD, DDA, DAD, DDA,

obtained by replacing B and C by D in the permutations of A, B, and C given earlier.However, these 6 permutations can be divided into the n!/k! = 3!/2! = 3 groups

ADD,ADD, DAD,DAD, DDA, DDA,

each having k! = 2! = 2 indistinguishable permutations.

(b) One solution is to extend the argument in (a) above: for each object type i, thereare ki! indistinguishable permutations of the ki objects. Hence, for any given orderedsequence, there are k1!k2! · · · kr ! indistinguishable permutations.

An alternative argument goes as follows. Choosing an ordered sequence is thesame as starting with n slots and for each i, choosing the ki slots to be occupied byobjects of type i. This is the same as partitioning the set 1, . . . , n into groups of sizek1, . . . , kr and the number of such partitions is given by the multinomial coefficient.

Problem 51. * Hypergeometric probabilities. An urn contains n balls, out ofwhich m are red. We select k of the balls at random, without replacement (i.e., selectedballs are not put back into the urn before the next selection). What is the probabilitythat i of the selected balls are red? It is assumed that i ≤ k ≤ n.

Solution. The sample space consists of the(

nk

)different ways that we can select k out

of the available balls. For the event of interest to materialize, we have to select i out ofthe m red balls, which can be done in

(mi

)ways, and also select k− i out of the n−m

blue balls, which can be done in(

n−mk−i

)ways. Therefore, the desired probability is

(m

i

)(n−m

k − i

)

(n

k

) .

Page 80: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

2

Discrete Random Variables

Contents

2.1. Basic Concepts . . . . . . . . . . . . . . . . . . . . . . p. 22.2. Probability Mass Functions . . . . . . . . . . . . . . . . p. 42.3. Functions of Random Variables . . . . . . . . . . . . . . . p. 92.4. Expectation, Mean, and Variance . . . . . . . . . . . . . p. 112.5. Joint PMFs of Multiple Random Variables . . . . . . . . . p. 222.6. Conditioning . . . . . . . . . . . . . . . . . . . . . . p. 272.7. Independence . . . . . . . . . . . . . . . . . . . . . . p. 362.8. Summary and Discussion . . . . . . . . . . . . . . . . p. 42

1

Page 81: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

2 Discrete Random Variables Chap. 2

2.1 BASIC CONCEPTS

In many probabilistic models, the outcomes are of a numerical nature, e.g., ifthey correspond to instrument readings or stock prices. In other experiments,the outcomes are not numerical, but they may be associated with some numericalvalues of interest. For example, if the experiment is the selection of students froma given population, we may wish to consider their grade point average. Whendealing with such numerical values, it is often useful to assign probabilities tothem. This is done through the notion of a random variable, the focus of thepresent chapter.

Given an experiment and the corresponding set of possible outcomes (thesample space), a random variable associates a particular number with each out-come; see Fig. 2.1. We refer to this number as the numerical value or theexperimental value of the random variable. Mathematically, a random vari-able is a real-valued function of the experimental outcome.

11 2

2

3

3

4

4

Real Number Line

1 2 3 4

(a)

(b)

Sample SpaceΩ x

Random Variable X

Real Number Line

Random Variable:X = Maximum Roll

Sample Space:Pairs of Rolls

Figure 2.1: (a) Visualization of a random variable. It is a function that assignsa numerical value to each possible outcome of the experiment. (b) An exampleof a random variable. The experiment consists of two rolls of a 4-sided die, andthe random variable is the maximum of the two rolls. If the outcome of theexperiment is (4, 2), the experimental value of this random variable is 4.

Here are some examples of random variables:

(a) In an experiment involving a sequence of 5 tosses of a coin, the number ofheads in the sequence is a random variable. However, the 5-long sequence

Page 82: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.1 Basic Concepts 3

of heads and tails is not considered a random variable because it does nothave an explicit numerical value.

(b) In an experiment involving two rolls of a die, the following are examples ofrandom variables:

(1) The sum of the two rolls.

(2) The number of sixes in the two rolls.

(3) The second roll raised to the fifth power.

(c) In an experiment involving the transmission of a message, the time neededto transmit the message, the number of symbols received in error, and thedelay with which the message is received are all random variables.

There are several basic concepts associated with random variables, whichare summarized below.

Main Concepts Related to Random Variables

Starting with a probabilistic model of an experiment:

• A random variable is a real-valued function of the outcome of theexperiment.

• A function of a random variable defines another random variable.

• We can associate with each random variable certain “averages” of in-terest, such the mean and the variance.

• A random variable can be conditioned on an event or on anotherrandom variable.

• There is a notion of independence of a random variable from anevent or from another random variable.

A random variable is called discrete if its range (the set of values thatit can take) is finite or at most countably infinite. For example, the randomvariables mentioned in (a) and (b) above can take at most a finite number ofnumerical values, and are therefore discrete.

A random variable that can take an uncountably infinite number of valuesis not discrete. For an example, consider the experiment of choosing a pointa from the interval [−1, 1]. The random variable that associates the numericalvalue a2 to the outcome a is not discrete. On the other hand, the random variablethat associates with a the numerical value

sgn(a) =

1 if a > 0,0 if a = 0,

−1 if a < 0,

is discrete.

Page 83: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

4 Discrete Random Variables Chap. 2

In this chapter, we focus exclusively on discrete random variables, eventhough we will typically omit the qualifier “discrete.”

Concepts Related to Discrete Random Variables

Starting with a probabilistic model of an experiment:

• A discrete random variable is a real-valued function of the outcomeof the experiment that can take a finite or countably infinite numberof values.

• A (discrete) random variable has an associated probability massfunction (PMF), which gives the probability of each numerical valuethat the random variable can take.

• A function of a random variable defines another random variable,whose PMF can be obtained from the PMF of the original randomvariable.

We will discuss each of the above concepts and the associated methodologyin the following sections. In addition, we will provide examples of some importantand frequently encountered random variables. In Chapter 3, we will discussgeneral (not necessarily discrete) random variables.

Even though this chapter may appear to be covering a lot of new ground,this is not really the case. The general line of development is to simply takethe concepts from Chapter 1 (probabilities, conditioning, independence, etc.)and apply them to random variables rather than events, together with someappropriate new notation. The only genuinely new concepts relate to means andvariances.

2.2 PROBABILITY MASS FUNCTIONS

The most important way to characterize a random variable is through the prob-abilities of the values that it can take. For a discrete random variable X, theseare captured by the probability mass function (PMF for short) of X, denotedpX . In particular, if x is any possible value of X, the probability mass of x,denoted pX (x), is the probability of the event X = x consisting of all outcomesthat give rise to a value of X equal to x:

pX (x) = P(X = x

).

For example, let the experiment consist of two independent tosses of a fair coin,and let X be the number of heads obtained. Then the PMF of X is

pX (x) =

1/4 if x = 0 or x = 2,1/2 if x = 1,0 otherwise.

Page 84: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.2 Probability Mass Functions 5

In what follows, we will often omit the braces from the event/set notation,when no ambiguity can arise. In particular, we will usually write P(X = x)in place of the more correct notation P

(X = x

). We will also adhere to

the following convention throughout: we will use upper case charactersto denote random variables, and lower case characters to denote realnumbers such as the numerical values of a random variable.

Note that ∑

x

pX (x) = 1,

where in the summation above, x ranges over all the possible numerical valuesof X. This follows from the additivity and normalization axioms, because theevents X = x are disjoint and form a partition of the sample space, as xranges over all possible values of X. By a similar argument, for any set S of realnumbers, we also have

P(X ∈ S) =∑

x∈S

pX(x).

For example, if X is the number of heads obtained in two independent tosses ofa fair coin, as above, the probability of at least one head is

P(X > 0) =∑

x>0

pX(x) =1

2+

1

4=

3

4.

Calculating the PMF of X is conceptually straightforward, and is illus-trated in Fig. 2.2.

Calculation of the PMF of a Random Variable X

For each possible value x of X:

1. Collect all the possible outcomes that give rise to the event X = x.2. Add their probabilities to obtain pX (x).

The Bernoulli Random Variable

Consider the toss of a biased coin, which comes up a head with probability p,and a tail with probability 1− p. The Bernoulli random variable takes the twovalues 1 and 0, depending on whether the outcome is a head or a tail:

X =

1 if a head,0 if a tail.

Its PMF is

pX(x) =

p if x = 1,1− p if x = 0.

Page 85: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

6 Discrete Random Variables Chap. 2

11 2

2

3

3

4

4

Sample Space:Pairs of Rolls

1 2 3 4

Random Variable:X = Maximum Roll

116

316

7165

16

(a)

(b)

Sample SpaceΩ

pX(x)

x

x

pX(x)

Event X=x

Figure 2.2: (a) Illustration of the method to calculate the PMF of a randomvariable X. For each possible value x, we collect all the outcomes that give riseto X = x and add their probabilities to obtain pX (x). (b) Calculation of thePMF pX of the random variable X = maximum roll in two independent rollsof a fair 4-sided die. There are four possible values x, namely, 1, 2, 3, 4. Tocalculate pX(x) for a given x, we add the probabilities of the outcomes that giverise to x. For example, there are three outcomes that give rise to x = 2, namely,(1, 2), (2, 2), (2, 1). Each of these outcomes has probability 1/16, so pX(2) = 3/16,as indicated in the figure.

For all its simplicity, the Bernoulli random variable is very important. Inpractice, it is used to model generic probabilistic situations with just two out-comes, such as:

(a) The state of a telephone at a given time that can be either free or busy.

(b) A person who can be either healthy or sick with a certain disease.

(c) The preference of a person who can be either for or against a certain po-litical candidate.

Furthermore, by combining multiple Bernoulli random variables, one can con-struct more complicated random variables.

Page 86: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.2 Probability Mass Functions 7

The Binomial Random Variable

A biased coin is tossed n times. At each toss, the coin comes up a head withprobability p, and a tail with probability 1−p, independently of prior tosses. LetX be the number of heads in the n-toss sequence. We refer to X as a binomialrandom variable with parameters n and p. The PMF of X consists of thebinomial probabilities that were calculated in Section 1.4:

pX(k) = P(X = k) =

(n

k

)pk(1 − p)n−k, k = 0,1, . . . , n.

(Note that here and elsewhere, we simplify notation and use k, instead of x, todenote the experimental values of integer-valued random variables.) The nor-malization property

∑x pX(x) = 1, specialized to the binomial random variable,

is written asn∑

k=0

(n

k

)pk(1− p)n−k = 1.

Some special cases of the binomial PMF are sketched in Fig. 2.3.

0 1 2 9876543

Binomial PMF n = 9, p = 1/2

0 n

Binomial PMF n = Large, p = Small

pX(k)

k

pX(k)

k

Figure 2.3: The PMF of a binomial random variable. If p = 1/2, the PMF issymmetric around n/2. Otherwise, the PMF is skewed towards 0 if p < 1/2, andtowards n if p > 1/2.

The Geometric Random Variable

Suppose that we repeatedly and independently toss a biased coin with probabilityof a head p, where 0 < p < 1. The geometric random variable is the numberX of tosses needed for a head to come up for the first time. Its PMF is given by

pX(k) = (1 − p)k−1p, k = 1, 2, . . . ,

since (1− p)k−1p is the probability of the sequence consisting of k− 1 successivetails followed by a head; see Fig. 2.4. This is a legitimate PMF because

∞∑

k=1

pX(k) =

∞∑

k=1

(1 − p)k−1p = p

∞∑

k=0

(1− p)k = p · 1

1− (1− p)= 1.

Page 87: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

8 Discrete Random Variables Chap. 2

Naturally, the use of coin tosses here is just to provide insight. Moregenerally, we can interpret the geometric random variable in terms of repeatedindependent trials until the first “success.” Each trial has probability of successp and the number of trials until (and including) the first success is modeled bythe geometric random variable.

k1

p

0 32

px(k)

Figure 2.4: The PMF

pX (k) = (1− p)k−1p, k = 1, 2, . . . ,

of a geometric random variable. It decreases as a geometric progression withparameter 1 − p.

The Poisson Random Variable

A Poisson random variable takes nonnegative integer values. Its PMF is givenby

pX(k) = e−λλk

k!, k = 0,1, 2, . . . ,

where λ is a positive parameter characterizing the PMF, see Fig. 2.5. It is alegitimate PMF because

∞∑

k=0

e−λλk

k!= e−λ

(1 + λ +

λ2

2!+

λ3

3!+ · · ·

)= e−λeλ = 1.

To get a feel for the Poisson random variable, think of a binomial randomvariable with very small p and very large n. For example, consider the numberof typos in a book with a total of n words, when the probability p that any oneword is misspelled is very small (associate a word with a coin toss which comesa head when the word is misspelled), or the number of cars involved in accidentsin a city on a given day (associate a car with a coin toss which comes a headwhen the car has an accident). Such a random variable can be well-modeled asa Poisson random variable.

Page 88: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.3 Functions of Random Variables 9

k

px(k)

1

e −λ ~ 0.6

0 32

Poisson λ = 0.5 Poisson λ = 3

k

px(k)

1

e −λ ~ 0.05

0 32 4 65 7

Figure 2.5: The PMF e−λ λk

k! of the Poisson random variable for different valuesof λ. Note that if λ < 1, then the PMF is monotonically decreasing, while ifλ > 1, the PMF first increases and then decreases as the value of k increases (thisis shown in the end-of-chapter problems).

More precisely, the Poisson PMF with parameter λ is a good approximationfor a binomial PMF with parameters n and p, provided λ = np, n is very large,and p is very small, i.e.,

e−λλk

k!≈ n!

(n− k)!k!pk(1− p)n−k, k = 0, 1, . . . , n.

In this case, using the Poisson PMF may result in simpler models and calcula-tions. For example, let n = 100 and p = 0.01. Then the probability of k = 5successes in n = 100 trials is calculated using the binomial PMF as

100!

95! 5!0.015(1− 0.01)95 = 0.00290.

Using the Poisson PMF with λ = np = 100 · 0.01 = 1, this probability isapproximated by

e−11

5!= 0.00306.

We provide a formal justification of the Poisson approximation propertyin the end-of-chapter problems and also in Chapter 5, where we will furtherinterpret it, extend it, and use it in the context of the Poisson process.

2.3 FUNCTIONS OF RANDOM VARIABLES

Consider a probability model of today’s weather, let the random variable Xbe the temperature in degrees Celsius, and consider the transformation Y =1.8X + 32, which gives the temperature in degrees Fahrenheit. In this example,Y is a linear function of X, of the form

Y = g(X) = aX + b,

Page 89: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

10 Discrete Random Variables Chap. 2

where a and b are scalars. We may also consider nonlinear functions of thegeneral form

Y = g(X).

For example, if we wish to display temperatures on a logarithmic scale, we wouldwant to use the function g(X) = log X .

If Y = g(X) is a function of a random variable X, then Y is also a randomvariable, since it provides a numerical value for each possible outcome. This isbecause every outcome in the sample space defines a numerical value x for Xand hence also the numerical value y = g(x) for Y . If X is discrete with PMFpX , then Y is also discrete, and its PMF pY can be calculated using the PMFof X. In particular, to obtain pY (y) for any y, we add the probabilities of allvalues of x such that g(x) = y:

pY (y) =∑

x | g(x)=ypX(x).

Example 2.1. Let Y = |X| and let us apply the preceding formula for the PMFpY to the case where

pX(x) =

1/9 if x is an integer in the range [−4, 4],0 otherwise.

The possible values of Y are y = 0, 1, 2, 3, 4. To compute pY (y) for some givenvalue y from this range, we must add pX(x) over all values x such that |x| = y. Inparticular, there is only one value of X that corresponds to y = 0, namely x = 0.Thus,

pY (0) = pX(0) =1

9.

Also, there are two values of X that correspond to each y = 1, 2, 3, 4, so for example,

pY (1) = pX(−1) + pX(1) =2

9.

Thus, the PMF of Y is

pY (y) =

2/9 if y = 1, 2, 3, 4,1/9 if y = 0,0 otherwise.

For another related example, let Z = X2. To obtain the PMF of Z, wecan view it either as the square of the random variable X or as the square of therandom variable Y . By applying the formula pZ(z) =

∑x |x2=z pX(x) or the

formula pZ(z) =∑y | y2=z pY (y), we obtain

pZ(z) =

2/9 if z = 1, 4, 9, 16,1/9 if z = 0,0 otherwise.

Page 90: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.4 Expectation, Mean, and Variance 11

-4

pX(x)

x-3 -2 -1 0 1 2 3 4

pY(y)

y0 1 2 3 4

19

19

29

Y = |X|

Figure 2.7: The PMFs of X and Y = |X| in Example 2.1.

2.4 EXPECTATION, MEAN, AND VARIANCE

The PMF of a random variable X provides us with several numbers, the proba-bilities of all the possible values of X. It would be desirable to summarize thisinformation in a single representative number. This is accomplished by the ex-pectation of X, which is a weighted (in proportion to probabilities) average ofthe possible values of X .

As motivation, suppose you spin a wheel of fortune many times. At eachspin, one of the numbers m1,m2, . . . , mn comes up with corresponding proba-bility p1, p2, . . . , pn, and this is your monetary reward from that spin. What isthe amount of money that you “expect” to get “per spin”? The terms “expect”and “per spin” are a little ambiguous, but here is a reasonable interpretation.

Suppose that you spin the wheel k times, and that ki is the number of timesthat the outcome is mi. Then, the total amount received is m1k1 +m2k2 + · · ·+mnkn. The amount received per spin is

M =m1k1 + m2k2 + · · ·+ mnkn

k.

If the number of spins k is very large, and if we are willing to interpret proba-bilities as relative frequencies, it is reasonable to anticipate that mi comes up afraction of times that is roughly equal to pi:

pi ≈ki

k, i = 1, . . . , n.

Thus, the amount of money per spin that you “expect” to receive is

M =m1k1 + m2k2 + · · ·+ mnkn

k≈ m1p1 + m2p2 + · · ·+ mnpn.

Motivated by this example, we introduce an important definition.

Page 91: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

12 Discrete Random Variables Chap. 2

Expectation

We define the expected value (also called the expectation or the mean)

of a random variable X, with PMF pX (x), by†

E[X] =∑

x

xpX(x).

Example 2.2. Consider two independent coin tosses, each with a 3/4 probabilityof a head, and let X be the number of heads obtained. This is a binomial randomvariable with parameters n = 2 and p = 3/4. Its PMF is

pX(k) =

(1/4)2 if k = 0,2 · (1/4) · (3/4) if k = 1,(3/4)2 if k = 2,

so the mean is

E[X] = 0 ·(

1

4

)2

+ 1 ·(2 · 1

4· 3

4

)+ 2 ·

(3

4

)2

=24

16=

3

2.

It is useful to view the mean of X as a “representative” value of X, whichlies somewhere in the middle of its range. We can make this statement moreprecise, by viewing the mean as the center of gravity of the PMF, in the senseexplained in Fig. 2.8.

† When dealing with random variables that take a countably infinite num-ber of values, one has to deal with the possibility that the infinite sum

∑x xpX(x)

is not well-defined. More concretely, we will say that the expectation is well-defined if

∑x |x|pX(x) < ∞. In that case, it is known that the infinite sum∑

x xpX (x) converges to a finite value that is independent of the order in whichthe various terms are summed.

For an example where the expectation is not well-defined, consider a ran-dom variable X that takes the value 2k with probability 2−k, for k = 1,2, . . ..For a more subtle example, consider the random variable X that takes the val-ues 2k and −2k with probability 2−k, for k = 2, 3, . . .. The expectation is againundefined, even though the PMF is symmetric around zero and one might betempted to say that E[X] is zero.

Throughout this book, in lack of an indication to the contrary, we implicitlyassume that the expected value of the random variables of interest is well-defined.

Page 92: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.4 Expectation, Mean, and Variance 13

x

Center of Gravityc = Mean E[X]

Figure 2.8: Interpretation of the mean as a center of gravity. Given a bar witha weight pX(x) placed at each point x with pX (x) > 0, the center of gravity c isthe point at which the sum of the torques from the weights to its left are equalto the sum of the torques from the weights to its right, that is,

x

(x− c)pX (x) = 0, or c =∑

x

xpX (x),

and the center of gravity is equal to the mean E[X ].

There are many other quantities that can be associated with a randomvariable and its PMF. For example, we define the 2nd moment of the randomvariable X as the expected value of the random variable X2. More generally, wedefine the nth moment as E[Xn], the expected value of the random variableXn. With this terminology, the 1st moment of X is just the mean.

The most important quantity associated with a random variable X, otherthan the mean, is its variance, which is denoted by var(X) and is defined as

the expected value of the random variable(X −E[X]

)2, i.e.,

var(X) = E[(

X −E[X])2]

.

Since(X − E[X]

)2can only take nonnegative values, the variance is always

nonnegative.The variance provides a measure of dispersion of X around its mean. An-

other measure of dispersion is the standard deviation of X, which is definedas the square root of the variance and is denoted by σX :

σX =√

var(X).

The standard deviation is often easier to interpret, because it has the same unitsas X. For example, if X measures length in meters, the units of variance aresquare meters, while the units of the standard deviation are meters.

One way to calculate var(X), is to use the definition of expected value,

after calculating the PMF of the random variable(X − E[X]

)2. This latter

Page 93: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

14 Discrete Random Variables Chap. 2

random variable is a function of X , and its PMF can be obtained in the mannerdiscussed in the preceding section.

Example 2.3. Consider the random variable X of Example 2.1, which has thePMF

pX(x) =

1/9 if x is an integer in the range [−4, 4],0 otherwise.

The mean E[X] is equal to 0. This can be seen from the symmetry of the PMF ofX around 0, and can also be verified from the definition:

E[X ] =∑

x

xpX(x) =1

9

4∑

x=−4

x = 0.

Let Z =(X − E[X]

)2= X2. As in Example 2.1, we obtain

pZ(z) =

2/9 if z = 1, 4, 9, 16,1/9 if z = 0,0 otherwise.

The variance of X is then obtained by

var(X) = E[Z] =∑

z

zpZ(z) = 0 · 1

9+ 1 · 2

9+ 4 · 2

9+ 9 · 2

9+ 16 · 2

9=

60

9.

It turns out that there is an easier method to calculate var(X), which uses

the PMF of X but does not require the PMF of(X − E[X]

)2. This method is

based on the following rule.

Expected Value Rule for Functions of Random Variables

Let X be a random variable with PMF pX (x), and let g(X) be a real-valued function of X. Then, the expected value of the random variableg(X) is given by

E[g(X)

]=

x

g(x)pX(x).

Page 94: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.4 Expectation, Mean, and Variance 15

To verify this rule, we use the formula pY (y) =∑x | g(x)=y pX(x) derived

in the preceding section, we have

E[g(X)

]= E[Y ]

=∑

y

ypY (y)

=∑

y

y∑

x | g(x)=ypX (x)

=∑

y

x | g(x)=yypX(x)

=∑

y

x | g(x)=yg(x)pX(x)

=∑

x

g(x)pX(x).

Using the expected value rule, we can write the variance of X as

var(X) = E[(

X − E[X ])2

]=

x

(x− E[X]

)2pX(x).

Similarly, the nth moment is given by

E[Xn] =∑

x

xnpX(x),

and there is no need to calculate the PMF of Xn.

Example 2.3. (Continued) For the random variable X with PMF

pX(x) =

1/9 if x is an integer in the range [−4, 4],0 otherwise,

we have

var(X) = E[(

X −E[X])2

]

=∑

x

(x− E[X]

)2pX(x)

=1

9

4∑

x=−4

x2

since E[X] = 0

=1

9(16 + 9 + 4 + 1 + 0 + 1 + 4 + 9 + 16)

=60

9,

Page 95: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

16 Discrete Random Variables Chap. 2

which is consistent with the result obtained earlier.

As we have noted earlier, the variance is always nonnegative, but could it

be zero? Since every term in the formula∑

x

(x−E[X]

)2pX (x) for the variance

is nonnegative, the sum is zero if and only if(x− E[X])2pX(x) = 0 for every x.

This condition implies that for any x with pX (x) > 0, we must have x = E[X ]and the random variable X is not really “random”: its experimental value isequal to the mean E[X], with probability 1.

Variance

The variance var(X) of a random variable X is defined by

var(X) = E[(

X − E[X])2]

and can be calculated as

var(X) =∑

x

(x−E[X]

)2pX(x).

It is always nonnegative. Its square root is denoted by σX and is called thestandard deviation.

Let us now use the expected value rule for functions in order to derive someimportant properties of the mean and the variance. We start with a randomvariable X and define a new random variable Y , of the form

Y = aX + b,

where a and b are given scalars. Let us derive the mean and the variance of thelinear function Y . We have

E[Y ] =∑

x

(ax + b)pX(x) = a∑

x

xpX(x) + b∑

x

pX(x) = aE[X] + b.

Furthermore,

var(Y ) =∑

x

(ax + b− E[aX + b]

)2pX (x)

=∑

x

(ax + b− aE[X]− b

)2pX (x)

= a2∑

x

(x− E[X]

)2pX(x)

= a2var(X).

Page 96: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.4 Expectation, Mean, and Variance 17

Mean and Variance of a Linear Function of a Random Variable

Let X be a random variable and let

Y = aX + b,

where a and b are given scalars. Then,

E[Y ] = aE[X] + b, var(Y ) = a2var(X).

Let us also give a convenient formula for the variance of a random variableX with given PMF.

Variance in Terms of Moments Expression

var(X) = E[X2]−(E[X]

)2.

This expression is verified as follows:

var(X) =∑

x

(x− E[X]

)2pX (x)

=∑

x

(x2 − 2xE[X] +

(E[X]

)2)pX(x)

=∑

x

x2pX (x)− 2E[X]∑

x

xpX(x) +(E[X ]

)2 ∑

x

pX(x)

= E[X2]− 2(E[X]

)2+

(E[X]

)2

= E[X2]−(E[X]

)2.

We will now derive the mean and the variance of a few important randomvariables.

Example 2.4. Mean and Variance of the Bernoulli. Consider the experimentof tossing a biased coin, which comes up a head with probability p and a tail withprobability 1− p, and the Bernoulli random variable X with PMF

pX(k) =

p if k = 1,1 − p if k = 0.

Page 97: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

18 Discrete Random Variables Chap. 2

Its mean, second moment, and variance are given by the following calculations:

E[X] = 1 · p + 0 · (1− p) = p,

E[X2] = 12 · p + 0 · (1− p) = p,

var(X) = E[X2]−

(E[X ]

)2= p− p

2= p(1− p).

Example 2.5. Discrete Uniform Random Variable. What is the mean andvariance of the roll of a fair six-sided die? If we view the result of the roll as arandom variable X, its PMF is

pX(k) =

1/6 if k = 1, 2, 3, 4, 5, 6,0 otherwise.

Since the PMF is symmetric around 3.5, we conclude that E[X] = 3.5. Regardingthe variance, we have

var(X) = E[X2]−(E[X]

)2

=1

6(12 + 22 + 32 + 42 + 52 + 62)− (3.5)2,

which yields var(X) = 35/12.The above random variable is a special case of a discrete uniformly dis-

tributed random variable (or discrete uniform for short), which by definition,takes one out of a range of contiguous integer values, with equal probability. Moreprecisely, this random variable has a PMF of the form

pX(k) =

1

b− a + 1if k = a, a + 1, . . . , b,

0 otherwise,

where a and b are two integers with a < b; see Fig. 2.9.The mean is

E[X] =a + b

2,

as can be seen by inspection, since the PMF is symmetric around (a + b)/2. Tocalculate the variance of X , we first consider the simpler case where a = 1 andb = n. It can be verified by induction on n that

E[X2] =1

n

n∑

k=1

k2 =1

6(n + 1)(2n + 1).

We leave the verification of this as an exercise for the reader. The variance can nowbe obtained in terms of the first and second moments

var(X) = E[X2] −

(E[X]

)2

=1

6(n + 1)(2n + 1)− 1

4(n + 1)2

=1

12(n + 1)(4n + 2 − 3n − 3)

=n2 − 1

12.

Page 98: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.4 Expectation, Mean, and Variance 19

a b

b - a +11

px(k)

k

...

Figure 2.9: PMF of the discrete random variable that is uniformly dis-tributed between two integers a and b. Its mean and variance are

E[X ] =a + b

2, var(X) =

(b− a)(b− a + 2)

12.

For the case of general integers a and b, we note that the uniformly distributedrandom variable over [a, b] has the same variance as the uniformly distributed ran-dom variable over the interval [1, b− a + 1], since these two random variables differby the constant a−1. Therefore, the desired variance is given by the above formulawith n = b− a + 1, which yields

var(X) =(b− a + 1)2 − 1

12=

(b− a)(b− a + 2)

12.

Example 2.6. The Mean of the Poisson. The mean of the Poisson PMF

pX(k) = e−λ λk

k!, k = 0, 1, 2, . . . ,

can be calculated is follows:

E[X] =

∞∑

k=0

ke−λ λk

k!

=

∞∑

k=1

ke−λ λk

k!the k = 0 term is zero

= λ

∞∑

k=1

e−λ λk−1

(k − 1)!

= λ

∞∑

m=0

e−λ λm

m!let m = k − 1

= λ.

Page 99: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

20 Discrete Random Variables Chap. 2

The last equality is obtained by noting that∑∞

m=0e−λ λm

m! =∑∞

m=0pX(m) = 1 is

the normalization property for the Poisson PMF.A similar calculation shows that the variance of a Poisson random variable is

also λ (see the solved problems). We will have the occasion to derive this fact in anumber of different ways in later chapters.

Expected values often provide a convenient vehicle for choosing optimallybetween several candidate decisions that result in different expected rewards. Ifwe view the expected reward of a decision as its “average payoff over a largenumber of trials,” it is reasonable to choose a decision with maximum expectedreward. The following is an example.

Example 2.7. The Quiz Problem. This example, when generalized appro-priately, is a prototypical model for optimal scheduling of a collection of tasks thathave uncertain outcomes.

Consider a quiz game where a person is given two questions and must decidewhich question to answer first. Question 1 will be answered correctly with proba-bility 0.8, and the person will then receive as prize $100, while question 2 will beanswered correctly with probability 0.5, and the person will then receive as prize$200. If the first question attempted is answered incorrectly, the quiz terminates,i.e., the person is not allowed to attempt the second question. If the first questionis answered correctly, the person is allowed to attempt the second question. Whichquestion should be answered first to maximize the expected value of the total prizemoney received?

The answer is not obvious because there is a tradeoff: attempting first themore valuable but also more difficult question 2 carries the risk of never getting achance to attempt the easier question 1. Let us view the total prize money receivedas a random variable X, and calculate the expected value E[X ] under the twopossible question orders (cf. Fig. 2.10):

0.2

0.5

0.8

0.2

0.5 0.8

0.5

0.5

$ 0 $ 0

$ 1 0 0

$ 3 0 0

$ 2 0 0

$ 3 0 0

Question 1Answered 1st

Question 2Answered 1st

Figure 2.10: Sequential description of the sample space of the quiz problemfor the two cases where we answer question 1 or question 2 first.

Page 100: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.4 Expectation, Mean, and Variance 21

(a) Answer question 1 first : Then the PMF of X is (cf. the left side of Fig. 2.10)

pX(0) = 0.2, pX(100) = 0.8 · 0.5, pX(300) = 0.8 · 0.5,

and we have

E[X] = 0.8 · 0.5 · 100 + 0.8 · 0.5 · 300 = $160.

(b) Answer question 2 first : Then the PMF of X is (cf. the right side of Fig. 2.10)

pX(0) = 0.5, pX(200) = 0.5 · 0.2, pX(300) = 0.5 · 0.8,

and we have

E[X] = 0.5 · 0.2 · 200 + 0.5 · 0.8 · 300 = $140.

Thus, it is preferable to attempt the easier question 1 first.Let us now generalize the analysis. Denote by p1 and p2 the probabilities

of correctly answering questions 1 and 2, respectively, and by v1 and v2 the corre-sponding prizes. If question 1 is answered first, we have

E[X] = p1(1− p2)v1 + p1p2(v1 + v2) = p1v1 + p1p2v2,

while if question 2 is answered first, we have

E[X] = p2(1− p1)v2 + p2p1(v2 + v1) = p2v2 + p2p1v1.

It is thus optimal to answer question 1 first if and only if

p1v1 + p1p2v2 ≥ p2v2 + p2p1v1,

or equivalently, ifp1v1

1 − p1≥ p2v2

1− p2.

Thus, it is optimal to order the questions in decreasing value of the expressionpv/(1 − p), which provides a convenient index of quality for a question with prob-ability of correct answer p and value v. Interestingly, this rule generalizes to thecase of more than two questions (see the end-of-chapter problems).

We finally illustrate by example a common pitfall: unless g(X) is a linearfunction, it is not generally true that E

[g(X)

]is equal to g

(E[X]

).

Example 2.8. Average Speed Versus Average Time. If the weather is good(which happens with probability 0.6), Alice walks the 2 miles to class at a speed ofV = 5 miles per hour, and otherwise drives her motorcycle at a speed of V = 30miles per hour. What is the mean of the time T to get to class?

Page 101: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

22 Discrete Random Variables Chap. 2

The correct way to solve the problem is to first derive the PMF of T ,

pT (t) =

0.6 if t = 2/5 hours,0.4 if t = 2/30 hours,

and then calculate its mean by

E[T ] = 0.6 · 2

5+ 0.4 · 2

30=

4

15hours.

However, it is wrong to calculate the mean of the speed V ,

E[V ] = 0.6 · 5 + 0.4 · 30 = 15 miles per hour,

and then claim that the mean of the time T is

2

E[V ]=

2

15hours.

To summarize, in this example we have

T =2

V, and E[T ] = E

[2

V

]6= 2

E[V ].

2.5 JOINT PMFS OF MULTIPLE RANDOM VARIABLES

Probabilistic models often involve several random variables of interest. For exam-ple, in a medical diagnosis context, the results of several tests may be significant,or in a networking context, the workloads of several gateways may be of interest.All of these random variables are associated with the same experiment, samplespace, and probability law, and their values may relate in interesting ways. Thismotivates us to consider probabilities involving simultaneously the numerical val-ues of several random variables and to investigate their mutual couplings. In thissection, we will extend the concepts of PMF and expectation developed so far tomultiple random variables. Later on, we will also develop notions of conditioningand independence that closely parallel the ideas discussed in Chapter 1.

Consider two discrete random variables X and Y associated with the sameexperiment. The joint PMF of X and Y is defined by

pX,Y (x, y) = P(X = x, Y = y)

for all pairs of numerical values (x, y) that X and Y can take. Here and elsewhere,we will use the abbreviated notation P(X = x, Y = y) instead of the more precisenotations P(X = x ∩ Y = y) or P(X = x and Y = x).

Page 102: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.5 Joint PMFs of Multiple Random Variables 23

The joint PMF determines the probability of any event that can be specifiedin terms of the random variables X and Y . For example if A is the set of allpairs (x, y) that have a certain property, then

P((X,Y ) ∈ A

)=

(x,y)∈A

pX,Y (x, y).

In fact, we can calculate the PMFs of X and Y by using the formulas

pX(x) =∑

y

pX,Y (x, y), pY (y) =∑

x

pX,Y (x, y).

The formula for pX(x) can be verified using the calculation

pX(x) = P(X = x)

=∑

y

P(X = x, Y = y)

=∑

y

pX,Y (x, y),

where the second equality follows by noting that the event X = x is the unionof the disjoint events X = x, Y = y as y ranges over all the different values ofY . The formula for pY (y) is verified similarly. We sometimes refer to pX andpY as the marginal PMFs, to distinguish them from the joint PMF.

The example of Fig. 2.11 illustrates the calculation of the marginal PMFsfrom the joint PMF by using the tabular method. Here, the joint PMF of Xand Y is arranged in a two-dimensional table, and the marginal PMF of Xor Y at a given value is obtained by adding the table entries along acorresponding column or row, respectively.

Functions of Multiple Random Variables

When there are multiple random variables of interest, it is possible to generatenew random variables by considering functions involving several of these randomvariables. In particular, a function Z = g(X,Y ) of the random variables X andY defines another random variable. Its PMF can be calculated from the jointPMF pX,Y according to

pZ(z) =∑

(x,y) | g(x,y)=zpX,Y (x, y).

Furthermore, the expected value rule for functions naturally extends and takesthe form

E[g(X, Y )

]=

x,y

g(x, y)pX,Y (x, y).

The verification of this is very similar to the earlier case of a function of a singlerandom variable. In the special case where g is linear and of the form aX+bY +c,where a, b, and c are given scalars, we have

E[aX + bY + c] = aE[X ] + bE[Y ] + c.

Page 103: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

24 Discrete Random Variables Chap. 2

1 2 3 4

4

3

2

1

x

y

1/20

4/20

3/20

2/20

2/20

2/201/20

1/20

1/20

1/20

2/20 0

00

0

0

x

y

1/20

4/20

3/20

2/20

2/20

2/201/20

1/20

1/20

1/20

2/20 0

00

0

0

9/20

5/20

5/20

x

y

1/20

4/20

3/20

2/20

2/20

2/201/20

1/20

1/20

1/20

2/20 0

00

0

0

6/208/203/20 3/20

Column Sums:Marginal PMF PX(x)

Joint PMF PX,Y(x,y)

in tabular form

1/20

Row Sums:Marginal PMF PY(y)

Figure 2.11: Illustration of the tabular method for calculating marginal PMFsfrom joint PMFs. The joint PMF is represented by a table, where the number ineach square (x, y) gives the value of pX,Y (x, y). To calculate the marginal PMFpX(x) for a given value of x, we add the numbers in the column corresponding tox. For example pX (2) = 8/20. Similarly, to calculate the marginal PMF pY (y)for a given value of y, we add the numbers in the row corresponding to y. Forexample pY (2) = 5/20.

More than Two Random Variables

The joint PMF of three random variables X, Y , and Z is defined in analogy withthe above as

pX,Y,Z(x, y, z) = P(X = x, Y = y, Z = z),

for all possible triplets of numerical values (x, y, z). Corresponding marginalPMFs are analogously obtained by equations such as

pX,Y (x, y) =∑

z

pX,Y,Z(x, y, z),

Page 104: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.5 Joint PMFs of Multiple Random Variables 25

and

pX(x) =∑

y

z

pX,Y,Z(x, y, z).

The expected value rule for functions takes the form

E[g(X, Y, Z)

]=

x,y,z

g(x, y, z)pX,Y,Z(x, y, z),

and if g is linear and of the form aX + bY + cZ + d, then

E[aX + bY + cZ + d] = aE[X] + bE[Y ] + cE[Z] + d.

Furthermore, there are obvious generalizations of the above to more than threerandom variables. For example, for any random variables X1, X2, . . . , Xn andany scalars a1, a2, . . . , an, we have

E[a1X1 + a2X2 + · · ·+ anXn] = a1E[X1] + a2E[X2] + · · ·+ anE[Xn].

Example 2.9. Mean of the Binomial. Your probability class has 300 studentsand each student has probability 1/3 of getting an A, independently of any otherstudent. What is the mean of X, the number of students that get an A? Let

Xi =

1 if the ith student gets an A,0 otherwise.

Thus X1, X2, . . . , Xn are Bernoulli random variables with common mean p = 1/3and variance p(1− p) = (1/3)(2/3) = 2/9. Their sum

X = X1 + X2 + · · ·+ Xn

is the number of students that get an A. Since X is the number of “successes” inn independent trials, it is a binomial random variable with parameters n and p.

Using the linearity of X as a function of the Xi, we have

E[X] =

300∑

i=1

E[Xi] =

300∑

i=1

1

3= 300 · 1

3= 100.

If we repeat this calculation for a general number of students n and probability ofA equal to p, we obtain

E[X] =

n∑

i=1

E[Xi] =

n∑

i=1

p = np,

Page 105: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

26 Discrete Random Variables Chap. 2

Example 2.10. The Hat Problem. Suppose that n people throw their hats ina box and then each picks up one hat at random. What is the expected value ofX , the number of people that get back their own hat?

For the ith person, we introduce a random variable Xi that takes the value1 if the person selects his/her own hat, and takes the value 0 otherwise. SinceP(Xi = 1) = 1/n and P(Xi = 0) = 1 − 1/n, the mean of Xi is

E[Xi] = 1 · 1

n+ 0 ·

(1− 1

n

)=

1

n.

We now have

X = X1 + X2 + · · ·+ Xn,

so that

E[X] = E[X1] + E[X2] + · · · + E[Xn] = n · 1

n= 1.

Summary of Facts About Joint PMFs

Let X and Y be random variables associated with the same experiment.

• The joint PMF of X and Y is defined by

pX,Y (x, y) = P(X = x, Y = y).

• The marginal PMFs of X and Y can be obtained from the joint PMF,using the formulas

pX(x) =∑

y

pX,Y (x, y), pY (y) =∑

x

pX,Y (x, y).

• A function g(X, Y ) of X and Y defines another random variable, and

E[g(X,Y )

]=

x,y

g(x, y)pX,Y (x, y).

If g is linear, of the form aX + bY + c, we have

E[aX + bY + c] = aE[X] + bE[Y ] + c.

• The above have natural extensions to the case where more than tworandom variables are involved.

Page 106: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.6 Conditioning 27

2.6 CONDITIONING

If we have a probabilistic model and we are also told that a certain event A hasoccurred, we can capture this knowledge by employing the conditional instead ofthe original (unconditional) probabilities. As discussed in Chapter 1, conditionalprobabilities are like ordinary probabilities (satisfy the three axioms) except thatthey refer to a new universe in which event A is known to have occurred. In thesame spirit, we can talk about conditional PMFs which provide the probabilitiesof the possible values of a random variable, conditioned on the occurrence ofsome event. This idea is developed in this section. In reality though, there isnot much that is new, only an elaboration of concepts that are familiar fromChapter 1, together with a fair dose of new notation.

Conditioning a Random Variable on an Event

The conditional PMF of a random variable X, conditioned on a particularevent A with P(A) > 0, is defined by

pX|A(x) = P(X = x |A) =P

(X = x ∩ A

)

P(A).

Note that the events X = x ∩ A are disjoint for different values of x, theirunion is A, and, therefore,

P(A) =∑

x

P(X = x ∩A

).

Combining the above two formulas, we see that

x

pX|A(x) = 1,

so pX|A is a legitimate PMF.As an example, let X be the roll of a die and let A be the event that the

roll is an even number. Then, by applying the preceding formula, we obtain

pX|A(x) = P(X = x | roll is even)

=P(X = x and X is even)

P(roll is even)

=

1/3 if x = 2, 4,6,0 otherwise.

The conditional PMF is calculated similar to its unconditional counterpart:to obtain pX|A(x), we add the probabilities of the outcomes that give rise toX = x and belong to the conditioning event A, and then normalize by dividingwith P(A) (see Fig. 2.12).

Page 107: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

28 Discrete Random Variables Chap. 2

Sample SpaceΩ

pX|A(x|A)

x

Event X=x

Event AEvent X=x'

x'

Figure 2.12: Visualization and calculation of the conditional PMF pX|A(x). Foreach x, we add the probabilities of the outcomes in the intersection X = x ∩Aand normalize by diving with P(A).

Conditioning one Random Variable on Another

Let X and Y be two random variables associated with the same experiment. Ifwe know that the experimental value of Y is some particular y (with pY (y) > 0),this provides partial knowledge about the value of X. This knowledge is capturedby the conditional PMF pX|Y of X given Y , which is defined by specializingthe definition of pX|A to events A of the form Y = y:

pX|Y (x | y) = P(X = x |Y = y).

Using the definition of conditional probabilities, we have

pX|Y (x | y) =P(X = x, Y = y)

P(Y = y)=

pX,Y (x, y)

pY (y).

Let us fix some y, with pY (y) > 0 and consider pX|Y (x | y) as a functionof x. This function is a valid PMF for X: it assigns nonnegative values to eachpossible x, and these values add to 1. Furthermore, this function of x, has thesame shape as pX,Y (x, y) except that it is normalized by dividing with pY (y),which enforces the normalization property

x

pX|Y (x | y) = 1.

Figure 2.13 provides a visualization of the conditional PMF.The conditional PMF is often convenient for the calculation of the joint

PMF, using a sequential approach and the formula

pX,Y (x, y) = pY (y)pX|Y (x | y),

or its counterpartpX,Y (x, y) = pX(x)pY |X (y |x).

Page 108: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.6 Conditioning 29

x

y

y = 1

y = 2

y = 3

PMF pX,Y(x,y)

Conditional PMFpX|Y(x| 3)

"SLICE VIEW" of Conditional PMFpX|Y(x|y)

Conditional PMFpX|Y(x| 2)

Conditional PMFpX|Y(x| 1 )

x

x

x

Figure 2.13: Visualization of the conditional PMF pX|Y (x | y). For each y, weview the joint PMF along the slice Y = y and renormalize so that

x

pX|Y (x | y) = 1.

This method is entirely similar to the use of the multiplication rule from Chap-ter 1. The following examples provide an illustration.

Example 2.11. Professor May B. Right often has her facts wrong, and answerseach of her students’ questions incorrectly with probability 1/4, independently ofother questions. In each lecture May is asked 0, 1, or 2 questions with equal proba-bility 1/3. Let X and Y be the number of questions May is asked and the number ofquestions she answers wrong in a given lecture, respectively. To construct the jointPMF pX,Y (x, y), we need to calculate all the probabilities P(X = x, Y = y) for allcombinations of values of x and y. This can be done by using a sequential descrip-tion of the experiment and the multiplication rule pX,Y (x, y) = pY (y)pX|Y (x | y),as shown in Fig. 2.14. For example, for the case where one question is asked and isanswered wrong, we have

pX,Y (1, 1) = pX(x)pY |X(y | x) =1

4· 1

3=

1

12.

The joint PMF can be represented by a two-dimensional table, as shown in Fig.2.14. It can be used to calculate the probability of any event of interest. For

Page 109: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

30 Discrete Random Variables Chap. 2

instance, we have

P(at least one wrong answer) = pX,Y (1, 1) + pX,Y (2, 1) + pX,Y (2, 2)

=4

48+

6

48+

1

48.

.

1 2

0

2

1

x

y

9/48

6/48

16/48

1/48

12/48

4/48

00

0

0

0

0

2

1

2

1 1

0

X : Number ofquestions asked

Y : Number ofquestions answeredwrong

1/3

1/3

1/3

9/16

3/4

1/4

1/16

6/16

Prob: 1/48

Prob: 6/48

Prob: 9/48

Prob: 4/48

Prob: 12/48

Prob: 16/48

Joint PMF PX,Y(x,y)

in tabular form

Figure 2.14: Calculation of the joint PMF pX,Y (x, y) in Example 2.11.

Example 2.12. Consider four independent rolls of a 6-sided die. Let X be thenumber of 1’s and let Y be the number of 2’s obtained. What is the joint PMF ofX and Y ?

The marginal PMF pY is given by the binomial formula

pY (y) =

(4

y

)(1

6

)y (5

6

)4−y

, y = 0, 1, . . . , 4.

To compute the conditional PMF pX|Y , note that given that Y = y, X is thenumber of 1’s in the remaining 4 − y rolls, each of which can take the 5 values1, 3, 4, 5, 6 with equal probability 1/5. Thus, the conditional PMF pX|Y is binomialwith parameters 4 − y and p = 1/5:

pX|Y (x | y) =

(4− y

x

)(1

5

)x (4

5

)4−y−x

,

Page 110: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.6 Conditioning 31

for all x and y such that x, y = 0, 1, . . . , 4, and 0 ≤ x + y ≤ 4. The joint PMF isnow given by

pX,Y (x, y) = pY (y)pX|Y (x | y)

=

(4

y

)(1

6

)y (5

6

)4−y(

4− y

x

) (1

5

)x (4

5

)4−y−x

,

for all nonnegative integers x and y such that 0 ≤ x + y ≤ 4. For other values of xand y, we have pX,Y (x, y) = 0.

The conditional PMF can also be used to calculate the marginal PMFs. Inparticular, we have by using the definitions,

pX (x) =∑

y

pX,Y (x, y) =∑

y

pY (y)pX|Y (x | y).

This formula provides a divide-and-conquer method for calculating marginalPMFs. It is in essence identical to the total probability theorem given in Chap-ter 1, but cast in different notation. The following example provides an illustra-tion.

Example 2.13. Consider a transmitter that is sending messages over a computernetwork. Let us define the following two random variables:

X : the travel time of a given message, Y : the length of the given message.

We know the PMF of the travel time of a message that has a given length, and weknow the PMF of the message length. We want to find the (unconditional) PMFof the travel time of a message.

We assume that the length of a message can take two possible values: y = 102

bytes with probability 5/6, and y = 104 bytes with probability 1/6, so that

pY (y) =

5/6 if y = 102,1/6 if y = 104.

We assume that the travel time X of the message depends on its length Y andthe congestion level of the network at the time of transmission. In particular, thetravel time is 10−4Y secs with probability 1/2, 10−3Y secs with probability 1/3,and 10−2Y secs with probability 1/6. Thus, we have

pX|Y (x | 102) =

1/2 if x = 10−2,1/3 if x = 10−1,1/6 if x = 1,

pX|Y (x | 104) =

1/2 if x = 1,1/3 if x = 10,1/6 if x = 100.

To find the PMF of X, we use the total probability formula

pX(x) =∑

y

pY (y)pX|Y (x | y).

Page 111: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

32 Discrete Random Variables Chap. 2

We obtain

pX(10−2) =5

6· 1

2, pX(10−1) =

5

6· 1

3, pX(1) =

5

6· 1

6+

1

6· 1

2,

pX(10) =1

6· 1

3, pX(100) =

1

6· 1

6.

Note finally that one can define conditional PMFs involving more thantwo random variables, as in pX,Y |Z(x, y | z) or pX|Y,Z(x | y, z). The concepts andmethods described above generalize easily (see the end-of-chapter problems).

Summary of Facts About Conditional PMFs

Let X and Y be random variables associated with the same experiment.

• Conditional PMFs are similar to ordinary PMFs, but refer to a uni-verse where the conditioning event is known to have occurred.

• The conditional PMF of X given an event A with P(A) > 0, is definedby

pX|A(x) = P(X = x |A)

and satisfies ∑

x

pX|A(x) = 1.

• The conditional PMF of X given Y = y is related to the joint PMFby

pX,Y (x, y) = pY (y)pX|Y (x | y).

This is analogous to the multiplication rule for calculating probabilitiesand can be used to calculate the joint PMF from the conditional PMF.

• The conditional PMF of X given Y can be used to calculate themarginal PMFs with the formula

pX(x) =∑

y

pY (y)pX|Y (x | y).

This is analogous to the divide-and-conquer approach for calculatingprobabilities using the total probability theorem.

• There are natural extensions to the above involving more than tworandom variables.

Page 112: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.6 Conditioning 33

Conditional Expectation

A conditional PMF can be thought of as an ordinary PMF over a new uni-verse determined by the conditioning event. In the same spirit, a conditionalexpectation is the same as an ordinary expectation, except that it refers to thenew universe, and all probabilities and PMFs are replaced by their conditionalcounterparts. We list the main definitions and relevant facts below.

Summary of Facts About Conditional Expectations

Let X and Y be random variables associated with the same experiment.

• The conditional expectation of X given an event A with P(A) > 0, isdefined by

E[X |A] =∑

x

xpX|A(x |A).

For a function g(X), it is given by

E[g(X) |A

]=

x

g(x)pX|A(x |A).

• The conditional expectation of X given a value y of Y is defined by

E[X | Y = y] =∑

x

xpX|Y (x | y).

• We haveE[X] =

y

pY (y)E[X |Y = y].

This is the total expectation theorem.

• Let A1, . . . , An be disjoint events that form a partition of the samplespace, and assume that P(Ai) > 0 for all i. Then,

E[X] =

n∑

i=1

P(Ai)E[X |Ai].

Let us verify the total expectation theorem, which basically says that “theunconditional average can be obtained by averaging the conditional averages.”The theorem is derived using the total probability formula

pX(x) =∑

y

pY (y)pX|Y (x | y)

Page 113: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

34 Discrete Random Variables Chap. 2

and the calculation

E[X] =∑

x

xpX(x)

=∑

x

x∑

y

pY (y)pX|Y (x | y)

=∑

y

pY (y)∑

x

xpX|Y (x | y)

=∑

y

pY (y)E[X | Y = y].

The relation E[X] =∑n

i=1 P(Ai)E[X |Ai] can be verified by viewing it asa special case of the total expectation theorem. Let us introduce the randomvariable Y that takes the value i if and only if the event Ai occurs. Its PMF isgiven by

pY (i) =

P(Ai) if i = 1, 2, . . . , n,0 otherwise.

The total expectation theorem yields

E[X] =

n∑

i=1

P(Ai)E[X |Y = i],

and since the event Y = i is just Ai, we obtain the desired expression

E[X ] =

n∑

i=1

P(Ai)E[X |Ai].

The total expectation theorem is analogous to the total probability theo-rem. It can be used to calculate the unconditional expectation E[X] from theconditional PMF or expectation, using a divide-and-conquer approach.

Example 2.14. Messages transmitted by a computer in Boston through a datanetwork are destined for New York with probability 0.5, for Chicago with probability0.3, and for San Francisco with probability 0.2. The transit time X of a message israndom. Its mean is 0.05 secs if it is destined for New York, 0.1 secs if it is destinedfor Chicago, and 0.3 secs if it is destined for San Francisco. Then, E[X] is easilycalculated using the total expectation theorem as

E[X] = 0.5 · 0.05 + 0.3 · 0.1 + 0.2 · 0.3 = 0.115 secs.

Example 2.15. Mean and Variance of the Geometric Random Variable.You write a software program over and over, and each time there is probability p

Page 114: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.7 Independence 35

that it works correctly, independently from previous attempts. What is the meanand variance of X , the number of tries until the program works correctly?

We recognize X as a geometric random variable with PMF

pX(k) = (1− p)k−1p, k = 1, 2, . . . .

The mean and variance of X are given by

E[X ] =

∞∑

k=1

k(1− p)k−1p, var(X) =

∞∑

k=1

(k − E[X])2(1− p)k−1p,

but evaluating these infinite sums is somewhat tedious. As an alternative, we willapply the total expectation theorem, with A1 = X = 1 = first try is a success,A2 = X > 1 = first try is a failure, and end up with a much simpler calcula-tion.

If the first try is successful, we have X = 1, and

E[X |X = 1] = 1.

If the first try fails (X > 1), we have wasted one try, and we are back where westarted. So, the expected number of remaining tries is E[X], and

E[X |X > 1] = 1 + E[X ].

Thus,

E[X] = P(X = 1)E[X |X = 1] + P(X > 1)E[X |X > 1]

= p + (1− p)(1 + E[X]

),

from which we obtain

E[X] =1

p.

With similar reasoning, we also have

E[X2 |X = 1] = 1, E[X2 |X > 1] = E[(1 + X)2

]= 1 + 2E[X] + E[X2],

so thatE[X2] = p · 1 + (1− p)

(1 + 2E[X] + E[X2]

),

from which we obtain

E[X2] =1 + 2(1 − p)E[X ]

p,

and

E[X2] =

2

p2− 1

p.

We conclude that

var(X) = E[X2] −(E[X]

)2=

2

p2− 1

p− 1

p2=

1− p

p2.

Page 115: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

36 Discrete Random Variables Chap. 2

2.7 INDEPENDENCE

We now discuss concepts of independence related to random variables. Theseconcepts are analogous to the concepts of independence between events (cf. Chap-ter 1). They are developed by simply introducing suitable events involving thepossible values of various random variables, and by considering their indepen-dence.

Independence of a Random Variable from an Event

The independence of a random variable from an event is similar to the indepen-dence of two events. The idea is that knowing the occurrence of the conditioningevent tells us nothing about the value of the random variable. More formally,we say that the random variable X is independent of the event A if

P(X = x and A) = P(X = x)P(A) = pX (x)P(A), for all x,

which is the same as requiring that the two events X = x and A be in-dependent, for any choice x. As long as P(A) > 0, and using the definitionpX|A(x) = P(X = x and A)/P(A) of the conditional PMF, we see that indepen-dence is the same as the condition

pX|A(x) = pX(x), for all x.

Example 2.16. Consider two independent tosses of a fair coin. Let X be thenumber of heads and let A be the event that the number of heads is even. The(unconditional) PMF of X is

pX(x) =

1/4 if x = 0,

1/2 if x = 1,

1/4 if x = 2,

and P(A) = 1/2. The conditional PMF is obtained from the definition pX|A(x) =

P(X = x and A

)/P(A):

pX|A(x) =

1/2 if x = 0,

0 if x = 1,

1/2 if x = 2.

Clearly, X and A are not independent, since the PMFs pX and pX|A are different.For an example of a random variable that is independent of A, consider the randomvariable that takes the value 0 if the first toss is a head, and the value 1 if the firsttoss is a tail. This is intuitively clear and can also be verified by using the definitionof independence.

Page 116: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.7 Independence 37

Independence of Random Variables

The notion of independence of two random variables is similar. We say that tworandom variables X and Y are independent if

pX,Y (x, y) = pX(x) pY (y), for all x, y.

This is the same as requiring that the two events X = x and Y = y be in-dependent for every x and y. Finally, the formula pX,Y (x, y) = pX|Y (x | y)pY (y)shows that independence is equivalent to the condition

pX|Y (x | y) = pX (x), for all y with pY (y) > 0 and all x.

Intuitively, independence means that the experimental value of Y tells us nothingabout the value of X.

There is a similar notion of conditional independence of two random vari-ables, given an event A with P(A > 0. The conditioning event A defines a newuniverse and all probabilities (or PMFs) have to be replaced by their conditionalcounterparts. For example, X and Y are said to be conditionally indepen-dent, given a positive probability event A, if

P(X = x, Y = y |A) = P(X = x |A)P(Y = y |A), for all x and y,

or, in this chapter’s notation,

pX,Y |A(x, y) = pX|A(x)pY |A(y), for all x and y.

Once more, this is equivalent to

pX|Y,A(x | y) = pX|A(x) for all x and y such that pY |A(y) > 0.

As in the case of events (Section 1.4), conditional independence may not implyunconditional independence and vice versa. This is illustrated by the examplein Fig. 2.15.

If X and Y are independent random variables, then

E[XY ] = E[X]E[Y ],

as shown by the following calculation:

E[XY ] =∑

x

y

xypX,Y (x, y)

=∑

x

y

xypX(x)pY (y) by independence

=∑

x

xpX(x)∑

y

ypY (y)

= E[X]E[Y ].

Page 117: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

38 Discrete Random Variables Chap. 2

1 2 3 4

4

3

2

1

x

y

1/20

4/20

3/20

2/20

2/20

2/201/20

1/20

1/20

1/20

2/20 0

00

0

0

Figure 2.15: Example illustrating that conditional independence may not implyunconditional independence. For the PMF shown, the random variables X andY are not independent. For example, we have

pX|Y (1 | 1) = P(X = 1 |Y = 1) = 0 6= P(X = 1) = pX (1).

On the other hand, conditional on the event A = X ≤ 2, Y ≥ 3 (the shadedset in the figure), the random variables X and Y can be seen to be independent.In particular, we have

pX|Y,A(x | y) =

1/3 if x = 1,2/3 if x = 2,

for both values y = 3 and y = 4.

A very similar calculation also shows that if X and Y are independent, then

E[g(X)h(Y )

]= E

[g(X)

]E

[h(Y )

],

for any functions g and h. In fact, this follows immediately once we realize thatif X and Y are independent, then the same is true for g(X) and h(Y ). This isintuitively clear and its formal verification is left as an end-of-chapter problem.

Consider now the sum Z = X + Y of two independent random variablesX and Y , and let us calculate the variance of Z. We have, using the relationE[X + Y ] = E[X] + E[Y ],

var(Z) = E[(

X + Y −E[X + Y ])2]

= E[(

X + Y −E[X]−E[Y ])2]

= E[((

X − E[X])

+(Y − E[Y ]

))2]

= E[(

X − E[X])2]

+ E[(

Y − E[Y ])2]

+ 2E[(

X − E[X ])(

Y − E[Y ])]

= E[(

X − E[X])2]

+ E[(

Y − E[Y ])2]

.

Page 118: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.7 Independence 39

To justify the last equality, note that the random variables X−E[X] and Y −E[Y ]are independent (they are functions of the independent random variables X andY , respectively) and

E[(

X − E[X])(

Y − E[Y ])]

= E[(

X − E[X])]

E[(

Y − E[Y ])]

= 0.

We conclude that

var(Z) = var(X) + var(Y ).

Thus, the variance of the sum of two independent random variables is equal tothe sum of their variances. As an interesting contrast, note that the mean of thesum of two random variables is always equal to the sum of their means, even ifthey are not independent.

Summary of Facts About Independent Random Variables

Let A be an event, with P(A) > 0, and let X and Y be random variablesassociated with the same experiment.

• X is independent of the event A if

pX|A(x) = pX(x), for all x,

that is, if for all x, the events X = x and A are independent.

• X and Y are independent if for all possible pairs (x, y), the eventsX = x and Y = y are independent, or equivalently

pX,Y (x, y) = pX(x)pY (y), for all x, y.

• If X and Y are independent random variables, then

E[XY ] = E[X]E[Y ].

Furthermore, for any functions f and g, the random variables g(X)and h(Y ) are independent, and we have

E[g(X)h(Y )

]= E

[g(X)

]E

[h(Y )

].

• If X and Y are independent, then

var[X + Y ] = var(X) + var(Y ).

Page 119: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

40 Discrete Random Variables Chap. 2

Independence of Several Random Variables

All of the above have natural extensions to the case of more than two randomvariables. For example, three random variables X, Y , and Z are said to beindependent if

pX,Y,Z(x, y, z) = pX (x)pY (y)pZ(z), for all x, y, z.

If X, Y , and Z are independent random variables, then any three randomvariables of the form f(X), g(Y ), and h(Z), are also independent. Similarly, anytwo random variables of the form g(X, Y ) and h(Z) are independent. On theother hand, two random variables of the form g(X, Y ) and h(Y, Z) are usuallynot independent, because they are both affected by Y . Properties such as theabove are intuitively clear if we interpret independence in terms of noninter-acting (sub)experiments. They can be formally verified (see the end-of-chapterproblems), but this is sometimes tedious. Fortunately, there is general agree-ment between intuition and what is mathematically correct. This is basically atestament that the definitions of independence we have been using adequatelyreflect the intended interpretation.

Another property that extends to multiple random variables is the follow-ing. If X1,X2, . . . , Xn are independent random variables, then

var(X1 + X2 + · · ·+ Xn) = var(X1) + var(X2) + · · ·+ var(Xn).

This can be verified by a calculation similar to the one for the case of two randomvariables and is left as an exercise for the reader.

Example 2.17. Variance of the Binomial. We consider n independent cointosses, with each toss having probability p of coming up a head. For each i, we letXi be the Bernoulli random variable which is equal to 1 if the ith toss comes upa head, and is 0 otherwise. Then, X = X1 + X2 + · · · + Xn is a binomial randomvariable. By the independence of the coin tosses, the random variables X1, . . . , Xn

are independent, and

var(X) =

n∑

i=1

var(Xi) = np(1− p).

The formulas for the mean and variance of a weighted sum of randomvariables form the basis for many statistical procedures that estimate the meanof a random variable by averaging many independent samples. A typical case isillustrated in the following example.

Example 2.18. Mean and Variance of the Sample Mean. We wish toestimate the approval rating of a president, to be called C. To this end, we ask n

Page 120: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.7 Independence 41

persons drawn at random from the voter population, and we let Xi be a randomvariable that encodes the response of the ith person:

Xi =

1 if the ith person approves C’s performance,0 if the ith person disapproves C’s performance.

We model X1,X2, . . . ,Xn as independent Bernoulli random variables with commonmean p and variance p(1 − p). Naturally, we view p as the true approval rating ofC. We “average” the responses and compute the sample mean Sn, defined as

Sn =X1 + X2 + · · ·+ Xn

n.

Thus, Sn is the approval rating of C within our n-person sample.We have, using the linearity of Sn as a function of the Xi,

E[Sn] =

n∑

i=1

1

nE[Xi] =

1

n

n∑

i=1

p = p,

and making use of the independence of X1, . . . , Xn,

var(Sn) =

n∑

i=1

1

n2var(Xi) =

p(1− p)

n.

The sample mean Sn can be viewed as a “good” estimate of the approval rating.This is because it has the correct expected value, which is the approval rating p, andits accuracy, as reflected by its variance, improves as the sample size n increases.

Note that even if the random variables Xi are not Bernoulli, the same calcu-lation yields

var(Sn) =var(X)

n,

as long as the Xi are independent, with common mean E[X] and variance var(X).Thus, again, the sample mean becomes a very good estimate (in terms of variance)of the true mean E[X ], as the sample size n increases. We will revisit the propertiesof the sample mean and discuss them in much greater detail in Chapter 7, when wediscuss the laws of large numbers.

Example 2.19. Estimating Probabilities by Simulation. In many practicalsituations, the analytical calculation of the probability of some event of interest isvery difficult. However, if we have a physical or computer model that can generateoutcomes of a given experiment in accordance with their true probabilities, we canuse simulation to calculate with high accuracy the probability of any given event A.In particular, we independently generate with our model n outcomes, we record thenumber m that belong to the event A of interest, and we approximate P(A) by m/n.For example, to calculate the probability p = P(Heads) of a biased coin, we flip thecoin n times, and we approximate p with the ratio (number of heads recorded)/n.

Page 121: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

42 Discrete Random Variables Chap. 2

To see how accurate this process is, consider n independent Bernoulli randomvariables X1, . . . ,Xn, each with PMF

pXi (xi) =

P(A) if xi = 1,0 if xi = 0.

In a simulation context, Xi corresponds to the ith outcome, and takes the value 1if the ith outcome belongs to the event A. The value of the random variable

X =X1 + X2 + · · ·+ Xn

n

is the estimate of P(A) provided by the simulation. According to Example 2.17, Xhas mean P(A) and variance P(A)

(1−P(A)

)/n, so that for large n, it provides an

accurate estimate of P(A).

2.8 SUMMARY AND DISCUSSION

Random variables provide the natural tools for dealing with probabilistic mod-els in which the outcome determines certain numerical values of interest. Inthis chapter, we focused on discrete random variables, and developed the mainconcepts and some relevant tools. We also discussed several special random vari-ables, and derived their PMF, mean, and variance, as summarized in the tablethat follows.

Summary of Results for Special Random Variables

Discrete Uniform over [a, b]:

pX (k) =

1

b− a + 1if k = a, a + 1, . . . , b,

0 otherwise,

E[X] =a + b

2, var(X) =

(b− a)(b− a + 2)

12.

Bernoulli with Parameter p: (Describes the success or failure in a singletrial.)

pX(k) =

p if k = 1,1− p if k = 0,

E[X] = p, var(X) = p(1− p).

Page 122: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 43

Binomial with Parameters p and n: (Describes the number of successesin n independent Bernoulli trials.)

pX(k) =

(n

k

)pk(1− p)n−k, k = 0, 1, . . . , n,

E[X] = np, var(X) = np(1− p).

Geometric with Parameter p: (Describes the number of trials until thefirst success, in a sequence of independent Bernoulli trials.)

pX(k) = (1 − p)k−1p, k = 1, 2, . . . ,

E[X] =1

p, var(X) =

1− p

p2.

Poisson with Parameter λ: (Approximates the binomial PMF when nis large, p is small, and λ = np.)

pX(k) = e−λλk

k!, k = 0, 1, . . . ,

E[X] = λ, var(X) = λ.

We also considered multiple random variables, and introduced their jointand conditional PMFs, and associated expected values. Conditional PMFs areoften the starting point in probabilistic models and can be used to calculateother quantities of interest, such as marginal or joint PMFs and expectations,through a sequential or a divide-and-conquer approach. In particular, given theconditional PMF pX|Y (x | y):

(a) The joint PMF can be calculated by

pX,Y (x, y) = pY (y)pX|Y (x | y).

This can be extended to the case of three or more random variables, as in

pX,Y,Z(x, y, z) = pY (y)pY |Z(y | z)pX|Y,Z(x | y, z),

and is analogous to the sequential tree-based calculation method using themultiplication rule, discussed in Chapter 1.

(b) The marginal PMF can be calculated by

pX(x) =∑

y

pY (y)pX|Y (x | y),

Page 123: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

44 Discrete Random Variables Chap. 2

which generalizes the divide-and-conquer calculation method we discussedin Chapter 1.

(c) The divide-and-conquer calculation method in (b) above can be extendedto compute expected values using the total expectation theorem:

E[X] =∑

y

pY (y)E[X |Y = y].

The concepts and methods of this chapter extend appropriately to generalrandom variables (see the next chapter), and are fundamental for our subject.

Page 124: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 45

S O L V E D P R O B L E M S

SECTION 2.2. Probability Mass Functions

Problem 1. The MIT soccer team has 2 games scheduled for one weekend. MIThas a 0.4 probability of not losing the first game, and a 0.6 probability of not losingthe second game. If it does not lose, the team has a 50% chance of a win, and a 50%chance of a tie, independently of all other weekend events. MIT will receive 2 pointsfor a win, 1 for a tie, and 0 for a loss. Let X be the number of points the MIT teamearns over the weekend. Find the PMF of X.

Solution.This requires enumeration of the possibilities and straightforward computa-tion:

P(X = 0) = 0.6 · 0.4 = 0.24,

P(X = 1) = 0.4 · 0.5 · 0.4 + 0.6 · 0.5 · 0.6 = 0.26,

P(X = 2) = 0.4 · 0.5 · 0.4 + 0.6 · 0.5 · 0.6 + 0.4 · 0.5 · 0.6 · 0.5 = 0.32,

P(X = 3) = 0.4 · 0.5 · 0.6 · 0.5 + 0.4 · 0.5 · 0.6 · 0.5 = 0.12,

P(X = 4) = 0.4 · 0.5 · 0.6 · 0.5 = 0.06,

P(X > 4) = 0.

Problem 2. The Celtics and the Lakers are set to play a playoff series of n basketballgames, where n is odd. The Celtics have a probability p of winning any one game,independently of other games.

(a) Find values of p for which the Celtics would rather play n = 5 games rather thann = 3 games.

(b) For any k > 0, find the values for p for which n = 2k + 1 is better for the Celticsthan n = 2k − 1.

Solution.(a) If n = 5, the Celtics need to win 3, 4, or 5 games (we assume here that allgames are played even if the series is already decided). Thus the probability that theCeltics will win the series when n = 5 is the sum of the probabilities of 3, 4, or 5 wins:

(5

3

)p3(1− p)2 +

(5

4

)p4(1− p)1 +

(5

5

)p5(1− p)0

Similarly, the probability that the Celtics will win the series when n = 3 is(

3

2

)p2(1− p)1 +

(3

3

)p3(1− p)0.

We want to find p such that

10p3(1− p)2 + 5p4(1− p) + p5 > 3p2(1− p) + p3.

Page 125: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

46 Discrete Random Variables Chap. 2

We see that for this to hold we must have p > 12 .

(b) It turns out that for the general case, we need p > 12 as well. To prove this, let N

be the number of Celtics wins in the first 2k − 1 games. If A denotes the event thatthe Celtics win with n = 2k + 1, and B denotes the event that the Celtics win withn = 2k − 1, then

P(A) = P(N ≥ k + 1) + P(N = k) ·(1− (1− p)2

)+ P(N = k − 1) · p2,

P(B) = P(N ≥ k) = P(N = k) + P(N ≥ k + 1),

and therefore

P(A)−P(B) = P(N = k − 1) · p2 −P(N = k) · (1− p)2

=

(2k − 1

k − 1

)pk−1(1− p)kp2 −

(2k − 1

k

)(1− p)2pk(1− p)k−1.

By simplifying the above expression, it follows that for P(A) > P(B), we need p > 12 .

Problem 3. You go to a party with 500 guests. What is the probability thatexactly one other guest has the same birthday as you? Calculate this exactly andalso approximately by using the Poisson PMF. (For simplicity, exclude birthdays onFebruary 29.)

Solution.The number of guests that have the same birthday as you is binomial withp = 1/365 and n = 499. Thus the probability that exactly one other guest has thesame birthday is (

499

1

)1

365

(364

365

)498

≈ 0.3486.

Let λ = np = 499/365 ≈ 1.367. The Poisson approximation is e−λλ = e−1.367 · 1.367 ≈0.3483, which closely agrees with the correct probability based on the binomial.

Problem 4. * The matchbox problem – inspired by Banach’s smokinghabits. A smoker mathematician carries one matchbox in his right pocket and onein his left pocket. Each time he wants to light a cigarette he selects a matchbox fromthe two pockets with probability p = 1/2, independently of earlier selections. Thetwo matchboxes have initially N matches each. What is the PMF of the number ofremaining matches at the moment when the mathematician reaches for a match anddiscovers that the corresponding matchbox is empty? How can we generalize for thecase where the probabilities of a left and a right pocket selection are p and 1 − p,respectively?

Solution.Suppose that an empty box is first discovered in the left pocket. Let rk bethe conditional probability that the number of matches in the right pocket is k at thattime, where k = 0, 1, . . . ,N . This number is k if and only if exactly N − k right pocketselections precede the (N +1)st left pocket selection. Viewing a left and a right pocketselection as a “success” and a “failure,” respectively, the probability of this happeningis the probability of getting N successes in 2N − k trials. Thus

rk =

(2N − k

N

)(1

2

)2N−k

.

Page 126: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 47

The conditional probability of k matches in the left pocket given that an empty box isfirst discovered in the right pocket is also rk. Thus, by the total probability theorem,the unconditional probability that the number of matches in the other pocket is k atthe time when an empty box is first discovered is rk , i.e.,

pX(k) =

(2N − k

N

) (1

2

)2N−k

, k = 0, 1, . . . , N.

In the more general case, we must calculate separately the conditional probabil-ities of k matches in the other pocket, given that the left and the right pockets arefirst found empty. We must also calculate the probabilities that the left and the rightpockets are first found empty. We then apply the total probability theorem.

Problem 5. * Recursive computation of the binomial PMF. Let X be thebinomial random variable with parameters n and p. Show that the PMF can be com-puted, starting with pX(0) = (1− p)n, using the recursive formula

pX(k + 1) =p

1 − p· n − k

k + 1· pX(k), k = 0, 1, . . . , n − 1.

Solution.For k = 0, 1, . . . , n− 1, we have

pX(k + 1)

pX(k)=

(n

k+1

)pk+1(1− p)n−k−1

(nk

)pk(1− p)n−k

=p

1 − p· n − k

k + 1.

Problem 6. * Form of the binomial PMF. Consider the binomial random variableX with parameters n and p. Show that, as k increases, the PMF pX(k) first increasesmonotonically and then decreases monotonically, with the maximum obtained when kis the largest integer that is less or equal to (n + 1)p.

Solution.For k = 1, . . . , n, we have

pX(k)

pX(k − 1)=

(nk

)pk(1− p)n−k

(n

k−1

)pk−1(1− p)n−k+1

=(n− k + 1)p

k(1− p)=

(n + 1)p− pk

k − pk.

Thus if k ≤ (n + 1)p, or equivalently k − pk ≤ (n + 1)p− pk, the above ratio is greaterthan or equal to 1, and it follows that pX(k) is monotonically nondecreasing. Otherwise,the ratio is less than one, and pX(k) is monotonically decreasing, as required.

Problem 7. * Form of the Poisson PMF. Let X be the Poisson random variablewith parameter λ. Show that the PMF pX(k) increases monotonically with k up tothe point where k reaches the largest integer not exceeding λ, and after that decreasesmonotonically with k.

Solution.Using the expression for the Poisson PMF, we have

pX(k)

pX(k − 1)=

λk · e−λ

k!· (k − 1)!

λk−1 · e−λ=

λ

k.

Page 127: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

48 Discrete Random Variables Chap. 2

Thus if k < λ the ratio is greater than 1, and it follows that pX(k) is monotonicallyincreasing. Otherwise, the ratio is less than one, and pX(k) is monotonically decreasing,as required.

Problem 8. * Justification of the Poisson approximation property. Con-sider the PMF of the binomial random variable with parameters n and p. Show thatasymptotically, as

n →∞, p → 0,

while np is fixed at a given scalar λ, this PMF approaches the PMF of the Poissonrandom variable with parameter λ.

Solution.Write the binomial PMF as

pX(k) =n!

(n − k)!k!pk(1− p)n−k

=n(n − 1) · · · (n − k + 1)

nk· λk

k!·(1− λ

n

)n−k

.

Fix k, and let n →∞ with λ = np fixed. We have, for j = 1, . . . , k,

n− k + j

n→ 1,

(1− λ

n

)k

→ 1,(1 − λ

n

)n

→ e−λ.

Thus, for each fixed k, as n → ∞ we have

pX(k) → e−λ λk

k!.

SECTION 2.3. Functions of Random Variables

Problem 9. Let X be a random variable that takes values from 0 to 9 with equalprobability 1/10.

(a) Find the PMF of the random variable Y = X mod(3).

(b) Find the PMF of the random variable Z = 5 mod(X + 1).

Solution.(a) Using the formula pY (y) =∑x | x (mod 3)=y pX(x), we obtain

pY (0) = pX(0) + pX(3) + pX(6) + pX(9) = 4/10,

pY (1) = pX(1) + pX(4) + pX(7) = 3/10,

pY (2) = pX(2) + pX(5) + pX(8) = 3/10,

pY (y) = 0 if y 6∈ 0, 1, 2.

(b) Similarly, using the formula pZ(z) =∑x | 5 mod(x+1)=z pX(x), we obtain

pZ(z) =

2/10 if z = 0,2/10 if z = 1,1/10 if z = 2,5/10 if z = 5,0 otherwise.

Page 128: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 49

SECTION 2.4. Expectation, Mean, and Variance

Problem 10. Consider the random variable X with PMF

pX(x) =

x2

a if x = −3,−2,−1, 0, 1, 2, 3,0 otherwise.

(a) Find a and E[X].

(b) What is the PMF of the random variable z = (x− E[X])2 ?

(c) Using part (b) compute the variance of X.

(d) Compute the variance of X using the expected value rule formula var(X) =∑x(x− E[X])2pX(x).

Solution.(a) a = 28 and E[X] = 0.

(b) If z ∈ 1, 4, 9, then

pZ(z) =∑

x |x2=z

pX(x) =z

28+

z

28=

z

14.

Otherwise pZ(z) = 0.

(c) var(X) = E[Z] =∑

z∈1,4,9z2

14 = 7.

(d) We have

var(X) =∑

x

(x− E[X])2pX(x)

= 12 ·(pX(−1) + pX(1)

)+ 22 ·

(pX(−2) + pX(2)

)+ 32 ·

(pX(−3) + pX(3)

)

= 2 · 1

28+ 8 · 4

28+ 18 · 9

28

= 7.

Problem 11. A city’s temperature is modeled as a random variable with mean andstandard deviation both equal to 10 degrees Celcius. A day is described as “normal”if the temperature within that day ranges with one standard deviation of the mean.What would be the temperature range for a normal day if temperature were expressedin Fahreneit degrees?

Solution.If X is the temperature in Celcius, the temperature in Fahreneit is Y = 32 +9X/5. Therefore, E[Y ] = 32 + 9E[X ]/5 = 32 + 18 = 40. Also var(Y ) = (9/5)2var(X),so the standard deviation of Y is (9/5) · 10 = 18. Hence a normal day in Fahreneit isone for which the temperature is in the range [22, 58].

Problem 12. Let a and b be positive integers with a ≤ b, and let X be the randomvariable that takes as values, with equal probability, the powers of 2 in the interval[2a, 2b]. Find the expected value and the variance of X.

Page 129: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

50 Discrete Random Variables Chap. 2

Solution. We have

pX(x) =

1

b−a+1 if x is a power of 2 in the interval [2a, 2b],0 otherwise,

and

E[X] =

b∑

k=a

1

b− a + 12k =

2a

b− a + 1(1 + 2 + · · · + 2b−a) =

2b+1 − 2a

b− a + 1.

Similarly,

E[X2] =

b∑

k=a

1

b− a + 1(2k)2 =

4b+1 − 4a

3(b− a + 1),

and finally

var(X) =4b+1 − 4a

3(b− a + 1)−

(2b+1 − 2a

b− a + 1

)2

.

Problem 13. Your friend proposes to play the following game with you. He will hidea $10 bill randomly in one of ten numbered boxes. You are to find the bill, and if youfind it, you can keep it. You must search for the bill by asking yes-no questions, andfor each question you ask, you must pay $1. The maximum amount of money that youwould you pay to play this game in order not to lose money on the average depends onthe playing strategy. What would be this amount if you were to play according to thefollowing strategies?

(a) Your questions must be: is it in box 1? is it in box 2? etc...

(b) On each guess you eliminate as close to half of the remaining numbers as possible.

Solution.We will find the expected gain according to each strategy, by computing theexpected number of questions until we find the bill.

(a) For this strategy, the expected number of guesses is

1

10

10∑

i=1

i =1

10· 55 = 5.5,

so we should be willing to pay no more than $4.50 to play with this strategy.

(b) For this strategy, the expected number of guesses is

4

10· 4 +

6

10· 3 = 3.4,

so we should be willing to pay $6.60 to play with this strategy. The above value wascomputed by enumeration, i.e., counting the number of numbers out of 10 that take 4guesses to find, and then counting the ones that take 3 guesses to find.

Problem 14. As an advertising campaign, a chocolate factory places golden ticketsin some of its candy bars, with the promise that a golden ticket is worth a trip through

Page 130: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 51

the chocolate factory, and all the chocolate you can eat for life. If the probability offinding a gold ticket is p, find the mean and the variance of the number of candy barsyou need to eat to find a ticket.

Solution.The number C of candy bars you need to eat is a geometric random variable.Thus the mean is E[C] = 1/p, and the variance is var(C) = (1− p)/p2.

Problem 15. St. Petersburg paradox. Consider the following game: you flip acoin, until the first tail appears. If the tail appears on the nth flip of the coin, youreceive 2n dollars. What is the expected gain for playing the game? How much wouldyou be willing to pay to play this game?

Solution.The expected value of the gain for a single game is infinite since if X is yourgain, then

E[X] =

∞∑

k=1

2k · 2−k =

∞∑

k=1

1 = ∞.

Thus if you are faced with the choice of playing for given fee f or not playing at all,and your objective is to make the choice that maximizes your expected net gain, youwould be willing to pay any value of f . However, this is in strong disagreement with thebehavior of individuals. In fact experiments have shown that most people are willingto pay only about $20 to $30 to play the game. The flaw in formulating the problem asone of choosing the option that maximizes your expected net gain does not take intoaccount your attitude towards risk taking.

Problem 16. * Mean and variance of the discrete uniform. Consider therandom variable X that takes the integer values a, a + 1, . . . , b with equal probability1/(b− a + 1). Compute its mean and variance.

Solution.By symmetry, the mean is E[X] = (a+ b)/2. Consider a translation of X, andin particular the special case where a = 1 and b = n. Then the mean is E[X] = (1+n)/2.Let us show by induction that the second moment is

E[X2] =1

n

n∑

k=1

k2 =1

6(n + 1)(2n + 1).

For n = 1 we have E[X2] = 1 and the above formula holds. Assume that the formulaholds for X uniformly distributed in the range 1, . . . , n, i.e.,

1

n

n∑

k=1

k2 =1

6(n + 1)(2n + 1).

We must show the formula for X uniformly distributed in the range 1, . . . , n + 1, i.e.,

1

n + 1

n+1∑

k=1

k2 =1

6(n + 2)(2n + 3).

Page 131: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

52 Discrete Random Variables Chap. 2

Indeed, we have using the induction hypothesis

1

n + 1

n+1∑

k=1

k2 =(n + 1)2

n + 1+

n

n + 1

1

n

n∑

k=1

k2

= n + 1 +n

n + 1

1

6(n + 1)(2n + 1)

= n + 1 +n(2n + 1)

6

=1

6

(6(n + 1) + n(2n + 1)

)

=1

6(n + 2)(2n + 3).

The variance is

var(X) = E[X2] −(E[X]

)2=

1

6(n + 1)(2n + 1)− (1 + n)2

4=

n2 − 1

12,

as shown in Example 2.5. For the case of general values a and b, we note that thevariance of a random variable is unaffected by a translation, so as in Example 2.5,var(X) is obtained by replacing n by b− a + 1 in the above formula.

Problem 17. * Mean and variance of the Poisson. Consider the Poisson randomvariable with parameter λ. Compute the second moment and the variance.

Solution.As shown in the text, the mean is given by

E[X] = λ.

Also

E[X2] =

∞∑

k=1

k2e−λ λk

k!= λ

∞∑

k=1

ke−λλk−1

(k − 1)!= λ

∞∑

m=0

(m + 1)e−λλm

m!

= λ(E[X ] + 1

)= λ(λ + 1),

from which

var(X) = E[X2]−(E[X ]

)2= λ(λ + 1)− λ2 = λ.

SECTION 2.5. Joint PMFs of Multiple Random Variables

Problem 18. PMF of the minimum of several random variables. On anygiven day your golf score is any integer from 101 to 110, each with probability 0.1.Determined to improve your score, you decide to play with three balls and declare asyour score the minimum X of the scores X1, X2, and X3 obtained with balls 1, 2, and3, respectively.

(a) Calculate the PMF of X.

(b) By how much has your expected score improved as a result of using three balls?

Page 132: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 53

Solution.(a) Consider the possible values of x1, x2 and x3 as coordinates in a cubicallattice of side 10. We can count all the points corresponding to min(x1, x2, x3) = 101.These points are trivial to count geometrically! They are the points in a cubical latticeof side 10, minus the points in a cubical lattice of side 9. Similarly, we can count thenumber of points corresponding to min(x1, x2, x3) = (111− k) as the number of pointsin a cubical lattice of side k, minus the number of points in a cubical lattice of side(k − 1). Since this problem follows a discrete uniform law, this counting solution issufficient to find the PMF:

pX(k) =

(111−k)3−(110−k)3

103100 < k ≤ 110,

0 otherwise.

(An alternative solution can be based on the notion of a CDF, which will be introducedin Chapter 3.)

(b) By symmetry, the expected value of the score on any particular ball is 105.5. Thiscan also be seen using the formula for expected value:

E[Xi] =

110∑

k=101

k · pXi (k) =

110∑

k=101

k1

10= 105.5.

We now need to calculate the expected value of X and compare it to the above:

E[X] =

∞∑

k=−∞

k · pX(k) =

110∑

k=101

k · px(k) =

110∑

k=101

k(111 − k)3 − (110 − k)3

103= 103.025.

The expected improvement is therefore 105.5 - 103.025 = 2.475.

Problem 19. * The quiz problem. Consider a quiz contest where a person is givena list of N questions and can answer these questions in any order he or she chooses.Question i will be answered correctly with probability pi, and the person will thenreceive a reward Vi. At the first incorrect answer, the quiz terminates and the personis allowed to keep his or her previous rewards. The problem is to choose the orderingof questions so as to maximize the expected value of total reward obtained. Show thatit is optimal to answer questions in a nonincreasing order of piVi/(1− pi).

Solution.We will use a so-called interchange argument, which is often useful in scheduling-like problems. Let i and j be the kth and (k + 1)st questions in an optimally orderedlist

L = (i1, . . . , ik−1, i, j, ik+2, . . . , iN ).

Consider the listL′= (i1, . . . , ik−1, j, i, ik+2, . . . , iN )

obtained from L by interchanging the order of questions i and j. We compute theexpected values of the rewards of L and L′, and argue that since L is optimally ordered,we have

E[reward of L] ≥ E[reward of L′].

Define the weight of question i to be

W (i) =piVi

(1− pi).

Page 133: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

54 Discrete Random Variables Chap. 2

We have to show that any permutation of the question in a non-increasing order ofweights maximizes the expected reward.

If L = (i1, . . . , iN ) is a permutation of the questions, define L(k) to be the per-mutation obtained from L by interchanging questions ik and ik+1. Let us first computethe difference between the expected reward of L and that of L(k). We have

E[reward of L] = pi1Vi1 + pi1pi2Vi2 + · · ·+ pi1 · · · piN ViN

and

E[reward of L(k)

] =pi1Vi1 + pi1pi2Vi2 + · · ·+ pi1 · · · pik−1Vik−1

+ pi1 · · · pik−1pik+1

Vik+1+ pi1 · · · pik−1

pik+1pik

Vik

+ pi1 · · · pik+1Vik+1 + · · ·+ pi1 · · · piN ViN

Therefore

E[reward of L(k)]− E[reward of L] = pi1 · · · pik−1

(pik+1

Vik+1+ pik+1

pikVik

− pikVik − pik pik+1Vik+1

)

= pi1 · · · pik−1(1− pik

)(1− pik+1)(W (ik+1)−W (ik)

).

Now, let us go back to our problem. Consider any permutation L of the questions.If W (ik) < W (ik+1) for some k, it follows from the above equation that the permutationL(k) has an expected reward larger than that of L. So, an optimal permutation of thequestions must be in a nonincreasing order of weights.

We still have to argue that any two such permutations have equal expectedrewards. Assume that L is such a permutation and say that W (ik) = W (ik+1) forsome k. We know that interchanging ik and ik+1 preserve the expected reward. So,the expected reward of any permutation L′ in a non-increasing order of weights is equalto that of L because L′ can be obtained from L by repeatedly interchanging adjacentquestions having equal weights.

Problem 20. * Verify the expected value rule

E[g(X, Y )

]=

x,y

g(x, y)pX,Y (x, y),

and its linear special case:

E[aX + bY ] = aE[X] + bE[Y ],

where a and b are given scalars.

Solution.Using the total expectation theorem to reduce the problem to the case of asingle random variable, we obtain

E[g(X,Y )

]=

y

pY (y)E[g(X, Y ) | y

]

=∑

y

pY (y)∑

x

g(x, y)pX|Y (x|y)

=∑

x,y

g(x, y)pX,Y (x, y)

Page 134: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 55

as desired. For the linear special case, we have

E[aX + bY ] =∑

x,y

(ax + by)pX,Y (x, y)

= a∑

x

x∑

y

pX,Y (x, y) + b∑

y

y∑

x

pX,Y (x, y)

= a∑

x

xpX(x) + b∑

y

ypY (y)

= aE[X ] + bE[Y ].

SECTION 2.6. Conditioning

Problem 21. We have m married couples (2m individuals). After a number ofyears, each person has died, independently, with probability p. Let N be the numberof surviving individuals. Let C be the number of couples in which both individuals arealive. Find E[C |N = n].

Solution.Let Xi = 1 if the male of the ith couple survives, Yi = 1 if the female of theith couple survives. (Let Xi and Yi be zero otherwise.) Then, C =

∑m

i=1XiYi. So, it

suffices to find E[XiYi |N = n]. Given N = n, Xi has probability n/2m of being alive.Given that N = n and Xi is alive, Yi has probability (n − 1)/(2m − 1) of being alive.So, E[XiYi |N = n] = n(n−1)/(2m)(2m−1), and E[C |N = n] = n(n−1)/2(2m−1).

Problem 22. A scalper is considering buying tickets for a particular game. Theprice of the tickets is $75, and the scalper will sell them at $150. However, if she can’tsell them at $150, she won’t sell them at all. Given that the demand for tickets isa binomial random variable with parameters n = 10 and p = 1/2, how many ticketsshould she buy in order to maximize her expected profit?

Solution.Let Q and b be the numbers of tickets demanded and bought, respectively. IfS is the number of tickets sold, then S = min(Q, b). The scalper’s expected profit is

r(b) = E[150S − 75b] = 150E[S] − 75b.

We first find E[S]. We assume that b ≤ 10, since clearly buying more than the maximumnumber of demanded tickets, which is 10, cannot be optimal. We have

E[S] = E[Q |Q ≤ b)]P(Q ≤ b) + E[Q |Q > b)]P(Q > b)

=

b∑

i=0

i

(10

i

) (1

2

)10

+ b

10∑

i=b+1

(10

i

) (1

2

)10

=(

1

2

)10(

b∑

i=0

i

(10

i

)+ b

b∑

i=0

(10

i

)).

Thus

r(b) = 150(

1

2

)10

(b∑

i=0

i

(10

i

)+ b

b∑

i=0

(10

i

))− 75b.

Page 135: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

56 Discrete Random Variables Chap. 2

Intuitively, r(b) first increases with n and then decreases. Thus, to find when r(b) ismaximized, we find the first value of b for which r(b + 1)− r(b) ≤ 0.

Problem 23. * D. Bernoulli’s problem of joint lives. Consider 2m personsforming m couples who live together at a given time. Suppose that at some later time,the probability of each person being alive is p, independently of other persons. At thatlater time, let A be the number of persons that are alive and let S be the number ofcouples in which both partners are alive. For any survivor number a, find E[S |A = a].

Solution.Let Xi be the random variable taking the value 1 or 0 depending on whetherthe first partner of the ith couple has survived or not. Let Yi be the correspondingrandom variable for the second partner of the ith couple. Then we have S =

∑m

i=1XiYi

and by using the total expectation theorem,

E[S |A = a] =

m∑

i=1

E[XiYi |A = a]

= mE[X1Y1 |A = a]

= mE[Y1 = 1 |X1 = 1, A = a]P(X1 = 1 |A = a)

= mP[Y1 = 1 |X1 = 1, A = a]P(X1 = 1 |A = a).

We have

P(Y1 = 1 |X1 = 1, A = a) =a− 1

2m − 1, P(X1 = 1 |A = a) =

a

2m.

Thus

E[S |A = a] = ma− 1

2m − 1

a

2m.

Note that E[S |A = a] does not depend on p.

Problem 24. * A biased coin is tossed successively until a head comes twice in arow or a tail comes twice in a row. The probability of a head is p and the probabilityof a tail is q = 1 − p. Find the expected value of the number of tosses until the gameis over.

Solution.One possibility here is to calculate the PMF of X, the number of tosses untilthe game is over, and use it to compute E[X]. However, this turns out to be cumber-some, so we argue by using the total expectation theorem and a suitable partition ofthe sample space. Let Hk (or Tk) be the event that a head (or a tail, respectively)comes at the kth toss. Since H1 and T1 form a partition of the sample space, andP(H1) = p and P(T1) = q, we have

E[X] = pE[X |H1] + qE[X | T1].

Using again the total expectation theorem, we have

E[X |H1] = pE[X |H1 ∩H2] + qE[X |H1 ∩ T2] = 2p + q(1 + E[X | T1]

),

where we have used the fact E[X |H1∩H2] = 2 (since the game ends after two successiveheads), and E[X |H1∩T2) = 1+E[X | T1] (since if the game is not over, only the last toss

Page 136: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 57

matters in determining the number of additional tosses up to termination). Similarly,we obtain

E[X | T1] = 2q + p(1 + E[X |H1]

).

Combining the above two relations, collecting terms, and using the fact p + q = 1, weobtain after some calculation

E[X | T1] =2 + p2

1 − pq,

and similarly

E[X |H1] =2 + q2

1 − pq.

Thus,

E[X ] = p · 2 + q2

1− pq+ q · 2 + p2

1− pq,

and finally, using the fact p + q = 1,

E[X] =2 + pq

1− pq.

In the case of a fair coin (p = q = 1/2), we obtain E[X ] = 3. It can also be verifiedthat 2 ≤ E[X ] ≤ 3 for all values of p.

Problem 25. * A spider and a fly move along a straight line. At each second, the flymoves a unit step to the right or to the left with equal probability p, and stays whereit is with probability 1−2p. The spider always takes a unit step in the direction of thefly. The spider and the fly start D units apart, where D is a random variable takingpositive integer values with a given PMF. If the spider lands on top of the fly, it’s theend. What is the expected value of T , the time it takes for this to happen?

Solution.Denote:

Ad the event that initially the spider and the fly are d units apart,

Bd the event that after one second the spider and the fly are d units apart.

Our approach will be to first apply the (conditional version of the) total expectationtheorem to compute E[T |A1], then use the result to compute E[T |A2], and similarlycompute sequentially E[T |Ad] for all relevant values of d. We will then apply the(unconditional version of the) total expectation theorem to compute E[T ].

We have

Ad = (Ad ∩ Bd) ∪ (Ad ∩ Bd−1) ∪ (Ad ∩ Bd−2), if d > 1.

This is because if the spider and the fly are at a distance d > 1 apart, then one secondlater their distance will be d (if the fly moved away from the spider) or d − 1 (if thefly did not move) or d− 2 (if the fly moved towards the spider). We also have, for thecase where the spider and the fly start one unit apart,

A1 = (A1 ∩ B1) ∪ (A1 ∩ B0).

Page 137: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

58 Discrete Random Variables Chap. 2

Using the total expectation theorem, we obtain

E[T |Ad] = P(Ad ∩ Bd)E[T |Ad ∩ Bd]

+ P(Ad ∩Bd−1)E[T |Ad ∩ Bd−1] if d > 1,

+ P(Ad ∩Bd−2)E[T |Ad ∩ Bd−2]

while for the case d = 1,

E[T |A1] = P(A1 ∩ B1)E[T |A1 ∩B1] + P(A1 ∩ B0)E[T |A1 ∩ B0].

It can be seen based on the problem data that

P(A1 ∩B1) = 2p, P(A1 ∩ B0) = 1 − 2p,

E[T |A1 ∩B1] = 1 + E[T |A1], E[T |A1 ∩ B0] = 1,

so by applying the theorem with d = 1, we obtain

E[T |A1] = 2p(1 + E[T |A1]

)+ (1− 2p),

or

E[T |A1] =1

1 − 2p.

By applying the theorem with d = 2, we obtain

E[T |A2] = pE[T |A2 ∩ B2] + (1− 2p)E[T |A2 ∩ B1] + pE[T |A2 ∩ B0].

We haveE[T |A2 ∩ B0] = 1,

E[T |A2 ∩ B1] = 1 + E[T |A1],

E[T |A2 ∩ B2] = 1 + E[T |A2],

so by substituting these relations in the expression for E[T |A2], we obtain

E[T |A2] = p(1 + E[T |A2]

)+ (1− 2p)

(1 + E[T |A1]

)+ p

= p(1 + E[T |A2]

)+ (1− 2p)

(1 +

1

1− 2p

)+ p.

This equation yields after some calculation

E[T |A2] =2

1− p.

Generalizing, we obtain

E[T |Ad] = p(1 + E[T |Ad]

)+ (1− 2p)

(1 + E[T |Ad−1]

)+ p

(1 + E[T |Ad−2]

)

Page 138: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 59

so E[T |Ad] can be generated recursively for any initial distance d, using as initialconditions the values of E[T |A1] and E[T |A2] obtained earlier.

Finally, the expected value of T can be obtained using the given PMF for theinitial distance D and the total expectation theorem:

E[T ] =∑

d

pD(d)E[T |Ad].

Problem 26. * The multiplication rule for conditional PMFs. Let X , Y , andZ be random variables.

(a) Show thatpX,Y,Z(x, y, z) = pX(x)pY |X(y |x)pZ |X,Y (z |x, y).

(b) How can we interpret this formula as a special case of the multiplication rulegiven in Section 1.3?

(c) Generalize to the case of more than three random variables.

Solution. (a) We have

pX,Y,Z(x, y, z) = P(X = x ∩ Y = y ∩ Z = z

)

= P(X = x)P(Y = y ∩ Z = z |X = x

)

= P(X = x)P(Y = y |X = x

)P

(Z = z | X = x ∩ Y = y

)

= pX(x)pY |X(y |x)pZ |X,Y (z |x, y).

(b) The formula can be written as

P(X = x ∩ Y = y ∩ Z = z

)

= P(X = x)P(Y = y |X = x

)P

(Z = z | X = x ∩ Y = y

),

which is a special case of the multiplication rule.

(c) The generalization is

pX1,...,Xn(x1, . . . , xn)

= pX1(x1)pX2|X1(x2|x1) · · · pXn|X1,...,Xn−1(xn|x1, . . . , xn−1).

Problem 27. * Splitting a Poisson random variable. A transmitter sends outeither a 1 with probability p, or a 0 with probability (1 − p), independently of earliertransmissions. If the number of transmissions within a given time interval is Poissonwith parameter λ, show that the number of 1’s transmitted in that same time intervalis also Poisson, and has parameter pλ.

Solution.Let X and Y be the numbers of 1’s and 0’s transmitted, respectively. LetZ = X + Y be the total number of symbols transmitted. We have

P(X = n, Y = m) = P(X = n, Y = m |Z = n + m)P(Z = n + m)

=

(n + m

n

)pn(1− p)m e−λλn+m

(n + m)!

=e−λp(λp)n

n!

e−λ(1−p)(λ(1− p)

)m

m!.

Page 139: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

60 Discrete Random Variables Chap. 2

Thus

P(X = n) =

∞∑

m=0

P(X = n, Y = m)

=e−λp(λp)n

n!e−λ(1−p)

∞∑

m=0

(λ(1− p)

)m

m!

=e−λp(λp)n

n!e−λ(1−p)eλ(1−p)

=e−λp(λp)n

n!,

so that X is Poisson with parameter λp.

SECTION 2.7. Independence

Problem 28. Alice passes through four traffic lights on her way to work, and eachlight is equally likely to be green or red, independently of the others.

(a) What is the PMF, the mean, and the variance of the number of red lights thatAlice encounters?

(b) Suppose that each red light delays Alice by exactly two minutes. What is thevariance of Alice’s commuting time?

Solution.(a) Let X be the number of red lights that Alice encounters. The PMF of X isbinomial with n = 4 and p = 1/2. The mean and the variance of X are E[X] = np = 2and var(X) = np(1− p) = 4 · (1/2) · (1/2) = 1.

(b) The variance of Alice’s commuting time is the same as the variance of the time bywhich Alice is delayed by the red lights. This is equal to the variance of 2X, which is4var(X) = 4.

Problem 29. Your computer has been acting very strangely lately, and you suspectthat it might have a virus on it. Unfortunately, all 12 of the different virus detectionprograms you own are somewhat outdated. You know that if your computer reallydoes have a virus, each of the programs, independently of the others, has a 0.8 chanceof correctly identifying your computer to be infected, and a 0.2 chance of thinking yourcomputer is fine. On the other hand, if your computer does not have a virus, eachprogram has a 0.9 chance of believing your computer to be free from viruses, and a 0.1chance of wrongly thinking your computer is infected. Given that your computer hasa 0.65 chance of being infected with some virus, and given that you will believe yourvirus protection programs only if 9 or more of them agree, find the probability thatyour detection programs will lead you to the right answer.

Solution.Let A denote the event that your detection programs lead you to the correctconclusion about your computer. Let V be the event that your computer has a virus,and let V c be the event that your computer does not have a virus. We have

P(A) = P(V )P(A |V ) + P(V c)P(A | V c),

Page 140: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 61

and P(A |V ) and P(A | V c) can be found using the binomial PMF. Thus we have

P(A |V ) =

(12

9

)· (0.8)9 · (0.2)3 +

(12

10

)· (0.8)10 · (0.2)2

+

(12

11

)· (0.8)

11 · (0.2)1

+

(12

12

)· (0.8)12 · (0.2)

0

= 0.7899.

Similarly we find that P(A |V c) = 0.9742, so that

P(A) = 0.65 · 0.7899 + 0.35 · 0.9742 = 0.8544.

Problem 30. A particular professor is known for his arbitrary grading policies. Infact, on any given paper, he gives any grade from the set A, A−, B+, B,B−, C+with equal probability. How many papers would you expect to hand in before havingreceived at least one of every grade in the range?

Solution.Let X6 be the number of papers until each grade is received at least once. LetX5 be the number of papers until a certain 5 out of the six grades is received at leastonce, and so on with X4, X3, etc. Then we have

E[X6] = 1 + E[X5],

E[X5] =1

6

(1 + E[X5]

)+

5

6

(1 + E[X4]

),

E[X4] =1

3

(1 + E[X4]

)+

2

3

(1 + E[X3]

),

E[X3] =1

2

(1 + E[X3]

)+

1

2

(1 + E[X2]

),

E[X2] =2

3

(1 + E[X2]

)+

1

3

(1 + E[X1]

),

E[X1] =5

6

(1 + E[X1]

)+

1

6(1),

and solving for E[X6], gives E[X6] = 14.7.

Alternative solution: Associate a success with a paper if its grade has not been receivedbefore. Let Xi be the number of papers between the ith success and the (i+1)st success.Then we have X = 1 +

∑5

i=1Xi and hence

E[X] = 1 +

5∑

i=1

E[Xi].

The random variable Xi is geometric with parameter pi = 6−i6 , so E[Xi] = 6

6−i . Itfollows that

E[X] = 1 +

5∑

i=1

6

6 − i= 1 + 6

5∑

i=1

1

i= 14.7.

Page 141: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

62 Discrete Random Variables Chap. 2

Problem 31. Each morning, Hungry Harry eats some eggs. On any given morning,the number of eggs he eats is equally likely to be 1, 2, 3, 4, 5, or 6, independently ofwhat he has done in the past. Let X be the number of eggs Harry eats in 10 days.Find the mean and variance of X .

Solution. Let Xi be the number of eggs Harry eats on day i. Then X =∑10

i=1Xi, and

therefore

E[X] = E

(10∑

i=1

Xi

)=

10∑

i=1

E[Xi] = 35.

Similarly, we have

var(X) = var

(10∑

i=1

Xi

)=

10∑

i=1

var(Xi)

since the Xi are independent. We can verify using the formula of Example 2.5, thatvar(Xi) ≈ 2.9167, so we have var(X) ≈ 29.167.

Problem 32. Computational problem. Here is a probabilistic method for com-puting the area of a given subset S of the unit square. The method uses a sequence ofindependent random selections of points in the unit square [0, 1]× [0, 1], according to auniform probability law. If the ith point belongs to the subset S the value of a randomvariable Xi is set to 1, and otherwise it is set to 0. Let X1, X2, . . . be the sequence ofrandom variables thus defined, and for any n, let

Sn =X1 + X2 + · · ·+ Xn

n.

(a) Show that E[Sn] is equal to the area of the subset S, and that var(Sn) diminishesto 0 as n increases.

(b) Show that if Sn−1 and Xn are known, this is enough to calculate Sn, so the pastXk, k = 1, . . . , n− 1, do not need to be remembered. Give a formula.

(c) Write a computer program to generate Sn for n = 1, 2, . . . , 10000 using the com-puter’s random number generator, for the case where the subset S is the circleinscribed within the unit square. How can you use your program to measureexperimentally the value of π?

(d) Use a similar computer program to calculate approximately the area of the setof all (x, y) that lie within the unit square and satisfy 0 ≤ cosπx + sinπy ≤ 1.

Solution.(a) Noting that

P(Xi = 1) =Area(S)

Area([0, 1]× [0, 1]

) = Area(S),

we obtain

E[Sn] = E

[1

n

n∑

i=1

Xi

]=

1

n

n∑

i=1

E[Xi] = E[Xi] = Area(S),

Page 142: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 63

and

var(Sn) = var

(1

n

n∑

i=1

Xi

)=

1

n2

n∑

i=1

var(Xi) =1

nvar(Xi) =

1

n

(1− Area(S)

)Area(S),

which tends to zero as n tends to infinity.

(b)

Sn =n − 1

nSn−1 +

1

nXn.

Problem 33. * Two biased coins are simultaneously tossed until one of them comesup a head and the other a tail. The first coin comes up a head with probability p andthe second with probability q.

(a) Find the PMF, the expected value, and the variance of the number of tosses untilthis happens.

(b) Assuming that p = q, what is the probability that the last toss of the first coinis a head?

(c) (Von Neumann coin) Suggest a method for generating a fair coin flip from a coinwhose probability of coming up heads is unknown. Hint: Use part (b).

Solution.(a) Let X be the number of tosses until the game is over. Noting that X isgeometric with probability of success

P(HT,TH) = p(1− q) + q(1− p),

we obtain

pX(k) = (pq + (1− p)(1− q))k−1(p(1− q) + q(1− p)), k = 1, 2, . . .

Therefore

E[X ] =1

p(1− q) + q(1− p)

and

var(X) =pq + (1− p)(1− q)(p(1− q) + q(1− p)

)2 .

(b) The probability that the last toss of the first coin is a head is

P(HT | HT,TH) =p(1− p)

p(1− p) + (1− p)p=

1

2.

(c) Keep on flipping the coin twice until two different outcomes appears. If the firstflip in the last pair of flips is a head declare a head, else declare a tail. The resultingflip is fair, because we know from part (b) that the probability of declaring a head is1/2.

Page 143: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

64 Discrete Random Variables Chap. 2

Problem 34. *

(a) A fair coin is tossed successively until two consecutive heads or two consecutivetails appear. Find the PMF, the expected value, and the variance of the numberof tosses until this happens.

(b) Assume now that the coin is tossed successively until a head followed by a tailappear. Find the PMF and the expected value of the number of tosses until untilthis happens.

Solution.Let X be the total number of tosses.

(a) If x ≥ 2, there are only two possible sequences of outcomes that lead to the eventX = x, the sequences HH and TT . Therefore,

P(X = x) = 2(1/2)x = (1/2)x−1.

It follows that

pX(x) =

(1/2)x−1 if x ≥ 2,0 otherwise.

and

E[X] =

∞∑

x=2

x(1/2)x−1 = 2

(−1/2 +

∞∑

x=1

x(1/2)x

)= 2

(−1/2 + 1/(1/2)

)= 3.

To find the variance of X, we first compute E[X2]. We have

E[X2] =

∞∑

x=2

x2(1/2)x−1 = 2

(−1/2 +

∞∑

x=1

x2(1/2)x

)= −1 + 2 · 6 = 11.

Thus

var(X) = 11− 32 = 2.

(b) If x > 2, there are x − 1 sequences of outcomes that lead to the event X = x,the first contains only heads in the first x − 2 trials and the others are determined bythe index of last occurrence of tail in the first x − 2 trials. For the case when x = 2,there is only one (hence x − 1) possible sequences of outcomes that lead to the eventX = x. Therefore, for any x ≥ 2,

P(X = x) = (x− 1)(1/2)x.

It follows that

pX(x) =

(x− 1)(1/2)x if x ≥ 2,0 otherwise,

and

E[X ] =

∞∑

x=2

x(x− 1)(1/2)x

=

∞∑

x=1

x2(1/2)

x −∞∑

x=1

x(1/2)x

= 4.

Page 144: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 65

Problem 35. * Suppose that X and Y are independent, identically distributed,geometric random variables with parameter p. Show that

P(X = i |X + Y = n) =1

n − 1, i = 1, . . . , n− 1.

Solution.We can interpret P(X = i |X + Y = n) as the probability that a coin willcome up a head for the first time on the ith toss given that it came up a head for thesecond time on the nth toss. We can then argue, intuitively, that given that the secondhead occurred on the nth toss, the first head is equally likely to have come up at anytoss between 1 and n− 1. To establish this precisely, note that we have

P(X = i |X + Y = n) =P(X = i and X + Y = n)

P(X + Y = n)=

P(X = i)P(Y = n− i)

P(X + Y = n).

Also P(X = i) = p(1−p)i−1 for i ≥ 1, and P(Y = n− i) = p(1−p)n−i−1 for n− i ≥ 1.It follows that P(X = i)P(Y = n − i) = p2(1 − p)n−2 for i = 1, . . . , n − 1 and 0otherwise. Therefore P(X = i |X + Y = n) = P(X = j |X + Y = n) for any i and jbetween 1 and n− 1. Hence

P(X = i |X + Y = n) =1

n − 1, i = 1, . . . , n− 1.

Problem 36. * Let X and Y be two random variables with given joint PMF, andlet g and h be two functions of X and Y , respectively. Show that if X and Y areindependent, then the same is true for the random variables g(X) and h(Y ).

Solution.Let G = g(X) and H = h(Y ). The independence of G and H follows fromthe calculation

pG,H(g, h) =∑

x,y | g(x)=g, h(y)=h

pX,Y (x, y)

=∑

x,y | g(x)=g, h(y)=h

pX(x)pY (y)

=∑

x | g(x)=g

pX(x)∑

x |h(y)=h

pY (y)

= pG(g)pH(h).

Problem 37. * Variability extremes. Let X1, . . . ,Xn be independent randomvariables and let X = X1 + · · ·+ Xn be their sum.

(a) Suppose that each Xi is Bernoulli with parameter pi, and that p1, . . . , pn arechosen so that the mean of X is a given µ > 0. Show that the variance of X ismaximized if the pi are chosen to be all equal to µ/n.

(b) Suppose that each Xi is geometric with parameter pi, and that p1, . . . , pn arechosen so that the mean of X is a given µ > 0. Show that the variance of Xis minimized if the pi are chosen to be all equal to n/µ. [Note the strikinglydifferent character of the results of parts (a) and (b).]

Page 145: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

66 Discrete Random Variables Chap. 2

Solution.(a) We have

var(X) =

n∑

i=1

var(Xi) =

n∑

i=1

pi(1− pi) = µ−n∑

i=1

p2i .

Thus maximizing the variance is equivalent to minimizing∑n

i=1p2

i . It can be seen(using the constraint that

∑n

i=1pi = µ) that

n∑

i=1

p2i =

n∑

i=1

(µ/n)2 +

n∑

i=1

(pi − µ/n)2,

so∑n

i=1p2

i is minimized when pi = µ/n for all i.

(b) We have

µ =

n∑

i=1

E[Xi] =

n∑

i=1

1

pi,

and

var(X) =

n∑

i=1

var(Xi) =

n∑

i=1

1− pi

p2i

.

Introducing the change of variables yi = 1/pi = E[Xi], we see that the constraintbecomes

n∑

i=1

yi = µ,

and that we must minimize

n∑

i=1

yi(yi − 1) =

n∑

i=1

y2i − µ

subject to that constraint. This is the same problem as the one of part (a), so themethod of proof given there applies.

Problem 38. * Entropy and uncertainty. Consider a random variable X thatcan take n values, x1, . . . , xn with corresponding probabilities p1, . . . , pn. The entropyof X is defined to be

H(X) = −n∑

i=1

pi log pi,

and is a measure of the uncertainty about the experimental value of X. To get asense of this, note that H(X) ≥ 0 and that H(X) is very close to 0 when X is “nearlydeterministic,” i.e., takes one of its possible values with probability very close to 1 (sincewe have p log p ≈ 0 if either p ≈ 0 or p ≈ 1). The notion of entropy is fundamental ininformation theory, which originated with C. Shannon’s famous work and is describedin many specialized textbooks. For example, it can be shown that H(X) is a lowerbound to the average number of yes-no questions (such as “is x = x1?” or “is x < x5?”)that must be asked in order to determine the experimental value of X that has occurred.

Page 146: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 2.8 Summary and Discussion 67

Furthermore, with a suitable strategy for asking questions and assuming a very longstring of experimental values of X, the average number of questions required per valuecan be made as close to H(X) as desired.

(a) Show that if q1, . . . , qn are nonnegative numbers such that∑n

i=1qi = 1, then

H(X) ≤ −n∑

i=1

pi log qi,

with equality if and only if pi = qi for all i. As a special case, show thatH(X) ≤ log n, with equality if and only if pi = 1/n for all i. Hint : Use theinequality ln α ≤ α−1, for α > 0, which holds with equality if and only if α = 1.(To see this, write ln α =

∫ α

1β−1δβ <

∫ α

1δβ = α − 1 for α > 1, and write

lnα = −∫ 1

αβ−1δβ < −

∫ 1

αδβ = α− 1 for 0 < α < 1.)

(b) Let X and Y be random variables taking a finite number of values, and havingjoint PMF pX,Y (x, y). Define

I(X, Y ) =∑

x

y

pX,Y (x, y) log

(pX,Y (x, y)

pX(x)pY (y)

).

Show that I(X,Y ) ≥ 0, and that I(X,Y ) = 0 if and only if X and Y areindependent.

(c) Show thatI(X, Y ) = H(X) + H(Y ) −H(X,Y ),

whereH(X,Y ) = −

x

y

pX,Y (x, y) log pX,Y (x, y),

H(X) = −∑

x

pX(x) log pX(x), H(Y ) = −∑

y

pY (y) log pY (y).

(d) Show thatI(X,Y ) = H(X) −H(X | Y ),

whereH(X |Y ) = −

x

y

pY (y)pX |Y (x | y) log pX |Y (x | y).

[Note that H(X | Y ) may be viewed as the conditional entropy of X given Y . Ifwe interpret I(X,Y ) as the information about X conveyed by Y , we can use theformula H(X | Y ) = H(X) − I(X,Y ) to view the conditional entropy H(X | Y )as the uncertainty about X reduced by the information about X conveyed by Y .]

Solution.(a) Using the inequality ln α ≤ α− 1, we have

−n∑

i=1

pi lnpi +

n∑

i=1

pi ln qi =

n∑

i=1

pi ln

(qi

pi

)≤

n∑

i=1

pi

(qi

pi− 1

)= 0,

Page 147: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

68 Discrete Random Variables Chap. 2

with equality if and only if pi = qi for all i. Since ln p = log p ln 2, we obtain the desiredrelation H(X) ≤ −

∑n

i=1pi log qi. The inequality H(X) ≤ log n is obtained by setting

qi = 1/n for all i.

(b) The numbers pX(x)pY (y) satisfy∑

x

∑y

pX(x)pY (y) = 1, so by part (a), we have

x

y

pX,Y (x, y) log(pX,Y (x, y)

)≥

x

y

pX,Y (x, y) log(pX(x)pY (y)

),

with equality if and only if

pX,Y (x, y) = pX(x)pY (y), for all x and y,

which is equivalent to X and Y being independent.

(c) We have

I(X, Y ) =∑

x

y

pX,Y (x, y) log pX,Y (x, y) −∑

x

y

pX,Y (x, y) log(pX(x)pY (y)

),

and ∑

x

y

pX,Y (x, y) log pX,Y (x, y) = −H(X,Y ),

−∑

x

y

pX,Y (x, y) log(pX(x)pY (y)

)= −

x

y

pX,Y (x, y) log pX(x)

−∑

x

y

pX,Y (x, y) log pY (y)

= −∑

x

pX(x) log pX(x)−∑

y

pY (y) log pY (y)

= H(X) + H(Y ).

Combining the above three relations, we obtain I(X,Y ) = H(X) + H(Y ) −H(X, Y ).

(d) From the calculation in part (c), we have

I(X, Y ) =∑

x

y

pX,Y (x, y) log pX,Y (x, y) −∑

x

pX(x) log pX(x)

−∑

x

y

pX,Y (x, y) log pY (y)

= H(X) +∑

x

y

pX,Y (x, y) log

(pX,Y (x, y)

pY (y)

)

= H(X) +∑

x

y

pY (y)pX |Y (x | y) log pX | Y (x | y)

= H(X)−H(X |Y ).

Page 148: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

3

General Random Variables

Contents

3.1. Continuous Random Variables and PDFs . . . . . . . . . . p. 23.2. Cumulative Distribution Functions . . . . . . . . . . . . p. 113.3. Normal Random Variables . . . . . . . . . . . . . . . . p. 173.4. Conditioning on an Event . . . . . . . . . . . . . . . . p. 213.5. Multiple Continuous Random Variables . . . . . . . . . . p. 273.6. Derived Distributions . . . . . . . . . . . . . . . . . . p. 393.7. Summary and Discussion . . . . . . . . . . . . . . . . p. 51

1

Page 149: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

2 General Random Variables Chap. 3

Random variables with a continuous range of possible experimental values arequite common – the velocity of a vehicle traveling along the highway could be oneexample. If such a velocity is measured by a digital speedometer, the speedome-ter’s reading is a discrete random variable. But if we also wish to model the exactvelocity, a continuous random variable is called for. Models involving continuousrandom variables can be useful for several reasons. Besides being finer-grainedand possibly more accurate, they allow the use of powerful tools from calculusand often admit an insightful analysis that would not be possible under a discretemodel.

All of the concepts and methods introduced in Chapter 2, such as expec-tation, PMFs, and conditioning, have continuous counterparts. Developing andinterpreting these counterparts is the subject of this chapter.

3.1 CONTINUOUS RANDOM VARIABLES AND PDFS

A random variable X is called continuous if its probability law can be describedin terms of a nonnegative function fX , called the probability density functionof X, or PDF for short, which satisfies

P(X ∈ B) =

B

fX(x) dx,

for every subset B of the real line.† In particular, the probability that the valueof X falls within an interval is

P(a ≤ X ≤ b) =

∫ b

a

fX(x) dx,

and can be interpreted as the area under the graph of the PDF (see Fig. 3.1).For any single value a, we have P(X = a) =

∫ a

a fX(x) dx = 0. For this reason,including or excluding the endpoints of an interval has no effect on its probability:

P(a ≤ X ≤ b) = P(a < X < b) = P(a ≤ X < b) = P(a < X ≤ b).

Note that to qualify as a PDF, a function fX must be nonnegative, i.e.,fX (x) ≥ 0 for every x, and must also satisfy the normalization equation

∫ ∞

−∞fX (x) dx = P(−∞ < X < ∞) = 1.

† The integral∫

BfX(x)dx is to be interpreted in the usual calculus/Riemann

sense and we implicitly assume that it is well-defined. For highly unusual functionsand sets, this integral can be harder – or even impossible – to define, but such issuesbelong to a more advanced treatment of the subject. In any case, it is comfortingto know that mathematical subtleties of this type do not arise if fX is a piecewisecontinuous function with a finite number of points of discontinuity, and B is the unionof a finite or countable number of intervals.

Page 150: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.1 Continuous Random Variables and PDFs 3

Sample Space

x

PDF fX(x)

Event a < X < b a b

Figure 3.1: Illustration of a PDF. The probability that X takes value in an

interval [a, b] is∫ b

afX (x) dx, which is the shaded area in the figure.

Graphically, this means that the entire area under the graph of the PDF mustbe equal to 1.

To interpret the PDF, note that for an interval [x, x + δ] with very smalllength δ, we have

P([x, x + δ]

)=

∫ x+δ

x

fX(t) dt ≈ fX(x) · δ,

so we can view fX(x) as the “probability mass per unit length” near x (cf.Fig. 3.2). It is important to realize that even though a PDF is used to calculateevent probabilities, fX(x) is not the probability of any particular event. Inparticular, it is not restricted to be less than or equal to one.

x

PDF fX(x )

δ

x + δ

Figure 3.2: Interpretation of the PDFfX (x) as “probability mass per unit length”around x. If δ is very small, the prob-ability that X takes value in the inter-val [x, x + δ] is the shaded area in thefigure, which is approximately equal tofX (x) · δ.

Example 3.1. Continuous Uniform Random Variable. A gambler spinsa wheel of fortune, continuously calibrated between 0 and 1, and observes theresulting number. Assuming that all subintervals of [0,1] of the same length areequally likely, this experiment can be modeled in terms a random variable X withPDF

fX(x) =

c if 0 ≤ x ≤ 1,0 otherwise,

Page 151: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

4 General Random Variables Chap. 3

for some constant c. This constant can be determined by using the normalizationproperty

1 =

∫ ∞

−∞fX(x) dx =

∫ 1

0

c dx = c

∫ 1

0

dx = c

so that c = 1.More generally, we can consider a random variable X that takes values in

an interval [a, b], and again assume that all subintervals of the same length areequally likely. We refer to this type of random variable as uniform or uniformlydistributed. Its PDF has the form

fX(x) =

c if a ≤ x ≤ b,0 otherwise,

where c is a constant. This is the continuous analog of the discrete uniform randomvariable discussed in Chapter 2. For fX to satisfy the normalization property, wemust have (cf. Fig. 3.3)

1 =

∫ b

a

c dx = c

∫ b

a

dx = c(b− a),

so that

c =1

b− a.

x

PDF fX(x)

a b

1b - a

Figure 3.3: The PDF of a uniformrandom variable.

Note that the probability P(X ∈ I) that X takes value in a set I is

P(X ∈ I) =

[a,b]∩I

1

b− adx =

1

b− a

[a,b]∩I

dx =length of [a, b] ∩ I

length of [a, b].

The uniform random variable bears a relation to the discrete uniform law, whichinvolves a sample space with a finite number of equally likely outcomes. The dif-ference is that to obtain the probability of various events, we must now calculatethe “length” of various subsets of the real line instead of counting the number ofoutcomes contained in various events.

Example 3.2. Piecewise Constant PDF. Alvin’s driving time to work isbetween 15 and 20 minutes if the day is sunny, and between 20 and 25 minutes if

Page 152: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.1 Continuous Random Variables and PDFs 5

the day is rainy, with all times being equally likely in each case. Assume that a dayis sunny with probability 2/3 and rainy with probability 1/3. What is the PDF ofthe driving time, viewed as a random variable X?

We interpret the statement that “all times are equally likely” in the sunnyand the rainy cases, to mean that the PDF of X is constant in each of the intervals[15, 20] and [20, 25]. Furthermore, since these two intervals contain all possibledriving times, the PDF should be zero everywhere else:

fX(x) =

c1 if 15 ≤ x < 20,c2 if 20 ≤ x ≤ 25,0 otherwise,

where c1 and c2 are some constants. We can determine these constants by usingthe given probabilities of a sunny and of a rainy day:

2

3= P(sunny day) =

∫ 20

15

fX(x) dx =

∫ 20

15

c1 dx = 5c1,

1

3= P(rainy day) =

∫ 25

20

fX(x) dx =

∫ 25

20

c2 dx = 5c2,

so that

c1 =2

15, c2 =

1

15.

Generalizing this example, consider a random variable X whose PDF has thepiecewise constant form

fX(x) =

ci if ai ≤ x < ai+1, i = 1, 2, . . . , n − 1,0 otherwise,

where a1, a2, . . . , an are some scalars with ai < ai+1 for all i, and c1, c2, . . . , cn aresome nonnegative constants (cf. Fig. 3.4). The constants ci may be determined byadditional problem data, as in the case of the preceding driving context. Generally,the ci must be such that the normalization property holds:

1 =

∫ an

a1

fX(x)dx =

n−1∑

i=1

∫ ai+1

ai

ci dx =

n−1∑

i=1

ci(ai+1 − ai).

x

PDF fX(x)

a 1 a 2 a 3 a 4

c 1

c 2

c 3

Figure 3.4: A piecewise constant PDF involving three intervals.

Page 153: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

6 General Random Variables Chap. 3

Example 3.3. A PDF can be arbitrarily large. Consider a random variableX with PDF

fX(x) =

1

2√

xif 0 < x ≤ 1,

0 otherwise.

Even though fX(x) becomes infinitely large as x approaches zero, this is still a validPDF, because ∫ ∞

−∞fX(x)dx =

∫ 1

0

1

2√

xdx =

√x

∣∣∣1

0= 1.

Summary of PDF Properties

Let X be a continuous random variable with PDF fX .

• fX(x) ≥ 0 for all x.

•∫∞−∞ fX(x) dx = 1.

• If δ is very small, then P([x, x + δ]

)≈ fX (x) · δ.

• For any subset B of the real line,

P(X ∈ B) =

B

fX(x) dx.

Expectation

The expected value or mean of a continuous random variable X is definedby†

E[X] =

∫ ∞

−∞xfX (x) dx.

† One has to deal with the possibility that the integral∫∞−∞ xfX(x) dx is infi-

nite or undefined. More concretely, we will say that the expectation is well-defined if∫∞−∞ |x|fX(x) dx < ∞. In that case, it is known that the integral

∫∞−∞ xfX(x)dx takes

a finite and unambiguous value.For an example where the expectation is not well-defined, consider a random vari-

able X with PDF fX(x) = c/(1 + x2), where c is a constant chosen to enforce the nor-malization condition. The expression |x|fX(x) is approximately the same as 1/|x| when|x| is large. Using the fact

∫∞1

(1/x)dx = ∞, one can show that∫∞−∞ |x|fX(x)dx = ∞.

Thus, E[X] is left undefined, despite the symmetry of the PDF around zero.Throughout this book, in lack of an indication to the contrary, we implicitly

assume that the expected value of the random variables of interest is well-defined.

Page 154: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.1 Continuous Random Variables and PDFs 7

This is similar to the discrete case except that the PMF is replaced by thePDF, and summation is replaced by integration. As in Chapter 2, E[X] can beinterpreted as the “center of gravity” of the probability law and, also, as theanticipated average value of X in a large number of independent repetitions ofthe experiment. Its mathematical properties are similar to the discrete case –after all, an integral is just a limiting form of a sum.

If X is a continuous random variable with given PDF, any real-valuedfunction Y = g(X) of X is also a random variable. Note that Y can be acontinuous random variable: for example, consider the trivial case where Y =g(X) = X . But Y can also turn out to be discrete. For example, suppose thatg(x) = 1 for x > 0, and g(x) = 0, otherwise. Then Y = g(X) is a discreterandom variable. In either case, the mean of g(X) satisfies the expected valuerule

E[g(X)

]=

∫ ∞

−∞g(x)fX (x) dx,

in complete analogy with the discrete case.The nth moment of a continuous random variable X is defined as E[Xn],

the expected value of the random variable Xn. The variance, denoted by

var(X), is defined as the expected value of the random variable(X − E[X]

)2.

We now summarize this discussion and list a number of additional factsthat are practically identical to their discrete counterparts.

Expectation of a Continuous Random Variable and its Properties

Let X be a continuous random variable with PDF fX .

• The expectation of X is defined by

E[X] =

∫ ∞

−∞xfX(x) dx.

• The expected value rule for a function g(X) has the form

E[g(X)

]=

∫ ∞

−∞g(x)fX(x) dx.

• The variance of X is defined by

var(X) = E[(

X − E[X ])2]

=

∫ ∞

−∞

(x− E[X]

)2fX(x) dx.

Page 155: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

8 General Random Variables Chap. 3

• We have0 ≤ var(X) = E[X2]−

(E[X]

)2.

• If Y = aX + b, where a and b are given scalars, then

E[Y ] = aE[X] + b, var(Y ) = a2var(X).

Example 3.4. Mean and Variance of the Uniform Random Variable.Consider the case of a uniform PDF over an interval [a, b], as in Example 3.1. Wehave

E[X] =

∫ ∞

−∞xfX(x)dx

=

∫ b

a

x · 1

b− adx

=1

b− a· 1

2x2

∣∣∣b

a

=1

b− a· b2 − a2

2

=a + b

2,

as one expects based on the symmetry of the PDF around (a + b)/2.To obtain the variance, we first calculate the second moment. We have

E[X2] =

∫ b

a

x2

b− adx

=1

b− a

∫ b

a

x2 dx

=1

b− a· 1

3x3

∣∣∣b

a

=b3 − a3

3(b− a)

=a2 + ab + b2

3.

Thus, the variance is obtained as

var(X) = E[X2] −(E[X]

)2=

a2 + ab + b2

3− (a + b)2

4=

(b− a)2

12,

after some calculation.

Page 156: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.1 Continuous Random Variables and PDFs 9

Suppose now that [a, b] = [0, 1], and consider the function g(x) = 1 if x ≤ 1/3,and g(x) = 2 if x > 1/3. The random variable Y = g(X) is a discrete one withPMF pY (1) = P(X ≤ 1/3) = 1/3, pY (2) = 1 − pY (1) = 2/3. Thus,

E[Y ] =1

3· 1 +

2

3· 2 =

5

3.

The same result could be obtained using the expected value rule:

E[Y ] =

∫ 1

0

g(x)fX(x)dx =

∫ 1/3

0

dx +

∫ 1

1/3

2dx =5

3.

Exponential Random Variable

An exponential random variable has a PDF of the form

fX (x) =

λe−λx if x ≥ 0,0 otherwise,

where λ is a positive parameter characterizing the PDF (see Fig. 3.5). This is alegitimate PDF because

∫ ∞

−∞fX(x) dx =

∫ ∞

0

λe−λx dx = −e−λx∣∣∣∞

0= 1.

Note that the probability that X exceeds a certain value falls exponentially.Indeed, for any a ≥ 0, we have

P(X ≥ a) =

∫ ∞

a

λe−λx dx = −e−λx

∣∣∣∞

a= e−λa.

An exponential random variable can be a very good model for the amountof time until a piece of equipment breaks down, until a light bulb burns out,or until an accident occurs. It will play a major role in our study of randomprocesses in Chapter 5, but for the time being we will simply view it as anexample of a random variable that is fairly tractable analytically.

0 x

λ

0 x

λ

Small λ Large λ

Figure 3.5: The PDF λe−λx of an exponential random variable.

Page 157: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

10 General Random Variables Chap. 3

The mean and the variance can be calculated to be

E[X ] =1

λ, var(X) =

1

λ2.

These formulas can be verified by straightforward calculation, as we now show.We have, using integration by parts,

E[X] =

∫ ∞

0

xλe−λx dx

= (−xe−λx)∣∣∣∞

0+

∫ ∞

0

e−λx dx

= 0− e−λx

λ

∣∣∣∣∣

0

=1

λ.

Using again integration by parts, the second moment is

E[X2] =

∫ ∞

0

x2λe−λx dx

= (−x2e−λx)∣∣∣∞

0+

∫ ∞

0

2xe−λx dx

= 0 +2

λE[X ]

=2

λ2.

Finally, using the formula var(X) = E[X2]−(E[X ]

)2, we obtain

var(X) =2

λ2− 1

λ2=

1

λ2.

Example 3.5. The time until a small meteorite first lands anywhere in the Saharadesert is modeled as an exponential random variable with a mean of 10 days. Thetime is currently midnight. What is the probability that a meteorite first landssome time between 6am and 6pm of the first day?

Let X be the time elapsed until the event of interest, measured in days.Then, X is exponential, with mean 1/λ = 10, which yields λ = 1/10. The desiredprobability is

P(1/4 ≤ X ≤ 3/4) = P(X ≥ 1/4)−P(X > 3/4) = e−1/40 − e−3/40 = 0.0476,

where we have used the formula P(X ≥ a) = P(X > a) = e−λa.

Page 158: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.2 Cumulative Distribution Functions 11

Let us also derive an expression for the probability that the time when ameteorite first lands will be between 6am and 6pm of some day. For the kth day,this set of times corresponds to the event k − (3/4) ≤ X ≤ k − (1/4). Since theseevents are disjoint, the probability of interest is

∞∑

k=1

P(

k − 3

4≤ X ≤ k − 1

4

)=

∞∑

k=1

(P

(X ≥ k − 3

4

)−P

(X > k − 1

4

))

=

∞∑

k=1

(e−(4k−3)/40 − e−(4k−1)/40

).

We omit the remainder of the calculation, which involves using the geometric seriesformula.

3.2 CUMULATIVE DISTRIBUTION FUNCTIONS

We have been dealing with discrete and continuous random variables in a some-what different manner, using PMFs and PDFs, respectively. It would be desir-able to describe all kinds of random variables with a single mathematical concept.This is accomplished by the cumulative distribution function, or CDF forshort. The CDF of a random variable X is denoted by FX and provides theprobability P(X ≤ x). In particular, for every x we have

FX(x) = P(X ≤ x) =

k≤x

pX (k) X: discrete,

∫ x

−∞fX(t) dt X: continuous.

Loosely speaking, the CDF FX (x) “accumulates” probability “up to” the value x.Any random variable associated with a given probability model has a CDF,

regardless of whether it is discrete, continuous, or other. This is because X ≤ xis always an event and therefore has a well-defined probability. Figures 3.6 and3.7 illustrate the CDFs of various discrete and continuous random variables.From these figures, as well as from the definition, some general properties of theCDF can be observed.

Page 159: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

12 General Random Variables Chap. 3

PMF pX(x)1

0 0

1

0 0x1 2 43 1 2 43

px(2) px(2)

CDF FX(x)PMF pX(x)

x x

x

CDF FX(x)

.. .

.. . .

Figure 3.6: CDFs of some discrete random variables. The CDF is related to thePMF through the formula

FX (x) = P(X ≤ x) =∑

k≤x

pX(k),

and has a staircase form, with jumps occurring at the values of positive probabilitymass. Note that at the points where a jump occurs, the value of FX is the largerof the two correponding values (i.e., FX is continuous from the right).

Properties of a CDF

The CDF FX of a random variable X is defined by

FX(x) = P(X ≤ x), for all x,

and has the following properties.

• FX is monotonically nondecreasing:

if x ≤ y, then FX (x) ≤ FX (y).

• FX(x) tends to 0 as x →−∞, and to 1 as x →∞.

• If X is discrete, then FX has a piecewise constant and staircase-likeform.

• If X is continuous, then FX has a continuously varying form.

Page 160: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.2 Cumulative Distribution Functions 13

• If X is discrete and takes integer values, the PMF and the CDF canbe obtained from each other by summing or differencing:

FX(k) =

k∑

i=−∞pX(i),

pX(k) = P(X ≤ k) −P(X ≤ k − 1) = FX(k) − FX (k − 1),

for all integers k.

• If X is continuous, the PDF and the CDF can be obtained from eachother by integration or differentiation:

FX(x) =

∫ x

−∞fX(t) dt,

fX(x) =dFX

dx(x).

(The latter relation is valid for those x for which the CDF has a deriva-tive.)

Because the CDF is defined for any type of random variable, it providesa convenient means for exploring the relations between continuous and discreterandom variables. This is illustrated in the following example, which showsthat there is a close relation between the geometric and the exponential randomvariables.

Example 3.6. The Geometric and Exponential CDFs. Let X be a geometricrandom variable with parameter p; that is, X is the number of trials to obtain thefirst success in a sequence of independent Bernoulli trials, where the probability ofsuccess is p. Thus, for k = 1, 2, . . ., we have P(X = k) = p(1− p)k−1 and the CDFis given by

F geo(n) =

n∑

k=1

p(1− p)k−1 = p1− (1− p)n

1− (1− p)= 1 − (1− p)n, for n = 1, 2, . . .

Suppose now that X is an exponential random variable with parameter λ > 0.Its CDF is given by

Fexp

(x) = P(X ≤ x) = 0, for x ≤ 0,

and

Fexp

(x) =

∫ x

0

λe−λt

dt = −e−λt

∣∣∣x

0= 1− e

−λx, for x > 0.

Page 161: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

14 General Random Variables Chap. 3

CDF FX(x)

x

PDF fX (x)

a b

1b - a

a b

1

a b

2b - a

a b

1

x - a

b - a

(x - a)2

(b - a)2

c c

Area = Fx(c)

CDF FX(x)

PDF fX (x)

x

x

x

Figure 3.7: CDFs of some continuous random variables. The CDF is related tothe PDF through the formula

FX (x) = P(X ≤ x) =

∫ x

−∞fX (t) dt.

Thus, the PDF fX can be obtained from the CDF by differentiation:

fX (x) =dFX (x)

dx.

For a continuous random variable, the CDF has no jumps, i.e., it is continuous.

To compare the two CDFs above, let δ = − ln(1− p)/λ, so that

e−λδ = 1− p.

Then we see that the values of the exponential and the geometric CDFs are equalfor all x = nδ, where n = 1, 2, . . ., i.e.,

F exp(nδ) = F geo(n), n = 1, 2, . . . ,

as illustrated in Fig. 3.8.If δ is very small, there is close proximity of the exponential and the geometric

CDFs, provided that we scale the values taken by the geometric random variable byδ. This relation is best interpreted by viewing X as time, either continuous, in thecase of the exponential, or δ-discretized, in the case of the geometric. In particular,suppose that δ is a small number, and that every δ seconds, we flip a coin with theprobability of heads being a small number p. Then, the time of the first occurrenceof heads is well approximated by an exponential random variable. The parameter

Page 162: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.2 Cumulative Distribution Functions 15

1

0 x

Geometric CDF

1 - (1 - p)n with p = 1 - e -λδ

δ

Exponential CDF 1 - e -λx

Figure 3.8: Relation of the geometric and the exponential CDFs. We have

F exp(nδ) = F geo(n), n = 1, 2, . . . ,

if the interval δ is such that e−λδ = 1− p. As δ approaches 0, the exponentialrandom variable can be interpreted as the “limit” of the geometric.

λ of this exponential is such that e−λδ = 1 − p or λ = − ln(1− p)/δ. This relationbetween the geometric and the exponential random variables will play an importantrole in the theory of the Bernoulli and Poisson stochastic processes in Chapter 5.

Sometimes, in order to calculate the PMF or PDF of a discrete or contin-uous random variable, respectively, it is more convenient to first calculate theCDF and then use the preceding relations. The systematic use of this approachfor the case of a continuous random variable will be discussed in Section 3.6.The following is a discrete example.

Example 3.7. The Maximum of Several Random Variables. You areallowed to take a certain test three times, and your final score will be the maximumof the test scores. Thus,

X = maxX1,X2, X3,

where X1,X2,X3 are the three test scores and X is the final score. Assume thatyour score in each test takes one of the values from 1 to 10 with equal probability1/10, independently of the scores in other tests. What is the PMF pX of the finalscore?

We calculate the PMF indirectly. We first compute the CDF FX(k) and thenobtain the PMF as

pX(k) = FX(k) − FX(k − 1), k = 1, . . . , 10.

Page 163: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

16 General Random Variables Chap. 3

We haveFX(k) = P(X ≤ k)

= P(X1 ≤ k, X2 ≤ k, X3 ≤ k)

= P(X1 ≤ k)P(X2 ≤ k)P(X3 ≤ k)

=(

k

10

)3

,

where the third equality follows from the independence of the events X1 ≤ k,X2 ≤ k, X3 ≤ k. Thus the PMF is given by

pX(k) =(

k

10

)3

−(

k − 1

10

)3

, k = 1, . . . , 10.

3.3 NORMAL RANDOM VARIABLES

A continuous random variable X is said to be normal or Gaussian if it has aPDF of the form (see Fig. 3.9)

fX (x) =1√2π σ

e−(x−µ)2/2σ2,

where µ and σ are two scalar parameters characterizing the PDF, with σ assumednonnegative. It can be verified that the normalization property

1√2π σ

∫ ∞

−∞e−(x−µ)2/2σ2

dx = 1

holds (see the end-of-chapter problems).

1 2-1 30

Normal PDF fx(x)

x 1 2-1 30 x

Normal CDF FX(x)

1

0.5

µ = 1 µ = 1

Figure 3.9: A normal PDF and CDF, with µ = 1 and σ2 = 1. We observe thatthe PDF is symmetric around its mean µ, and has a characteristic bell-shape.

As x gets further from µ, the term e−(x−µ)2/2σ2decreases very rapidly. In this

figure, the PDF is very close to zero outside the interval [−1, 3].

Page 164: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.3 Normal Random Variables 17

The mean and the variance can be calculated to be

E[X] = µ, var(X) = σ2.

To see this, note that the PDF is symmetric around µ, so its mean must be µ.Furthermore, the variance is given by

var(X) =1√2π σ

∫ ∞

−∞(x− µ)2e−(x−µ)2/2σ2

dx.

Using the change of variables y = (x− µ)/σ and integration by parts, we have

var(X) =σ2

√2π

∫ ∞

−∞y2e−y2/2 dy

=σ2

√2π

(−ye−y2/2

) ∣∣∣∣∞

−∞+

σ2

√2π

∫ ∞

−∞e−y2/2 dy

=σ2

√2π

∫ ∞

−∞e−y2/2 dy

= σ2.

The last equality above is obtained by using the fact

1√2π

∫ ∞

−∞e−y2/2 dy = 1,

which is just the normalization property of the normal PDF for the case whereµ = 0 and σ = 1.

The normal random variable has several special properties. The followingone is particularly important and will be justified in Section 3.6.

Normality is Preserved by Linear Transformations

If X is a normal random variable with mean µ and variance σ2, and if a, bare scalars, then the random variable

Y = aX + b

is also normal, with mean and variance

E[Y ] = aµ + b, var(Y ) = a2σ2.

Page 165: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

18 General Random Variables Chap. 3

The Standard Normal Random Variable

A normal random variable Y with zero mean and unit variance is said to be astandard normal. Its CDF is denoted by Φ,

Φ(y) = P(Y ≤ y) = P(Y < y) =1√2π

∫ y

−∞e−t2/2 dt.

It is recorded in a table (given in the next page), and is a very useful toolfor calculating various probabilities involving normal random variables; see alsoFig. 3.10.

Note that the table only provides the values of Φ(y) for y ≥ 0, because theomitted values can be found using the symmetry of the PDF. For example, if Yis a standard normal random variable, we have

Φ(−0.5) = P(Y ≤ −0.5) = P(Y ≥ 0.5) = 1−P(Y < 0.5)

= 1− Φ(0.5) = 1− .6915 = 0.3085.

Let X be a normal random variable with mean µ and variance σ2. We“standardize” X by defining a new random variable Y given by

Y =X − µ

σ.

Since Y is a linear transformation of X, it is normal. Furthermore,

E[Y ] =E[X]− µ

σ= 0, var(Y ) =

var(X)

σ2= 1.

Thus, Y is a standard normal random variable. This fact allows us to calculatethe probability of any event defined in terms of X : we redefine the event in termsof Y , and then use the standard normal table.

2-1 0

Standard Normal PDF

0.399Mean = 0

Variance = 1

2-1 0 y

Standard Normal CDFΦ(y )

1

0.7

Area = Φ(0.7) Φ(0.7)

0.7

Figure 3.10: The PDF

fY (y) =1√2π

e−y2/2

of the standard normal random variable. Its corresponding CDF, which is denotedby Φ(y), is recorded in a table.

Page 166: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.3 Normal Random Variables 19

Example 3.8. Using the Normal Table. The annual snowfall at a particulargeographic location is modeled as a normal random variable with a mean of µ = 60inches, and a standard deviation of σ = 20. What is the probability that this year’ssnowfall will be at least 80 inches?

Let X be the snow accumulation, viewed as a normal random variable, andlet

Y =X − µ

σ=

X − 60

20,

be the corresponding standard normal random variable. We want to find

P(X ≥ 80) = P(

X − 60

20≥ 80− 60

20

)= P

(Y ≥ 80− 60

20

)= P(Y ≥ 1) = 1−Φ(1),

where Φ is the CDF of the standard normal. We read the value Φ(1) from the table:

Φ(1) = 0.8413,

so that

P(X ≥ 80) = 1− Φ(1) = 0.1587.

Generalizing the approach in the preceding example, we have the followingprocedure.

CDF Calculation of the Normal Random Variable

The CDF of a normal random variable X with mean µ and variance σ2 isobtained using the standard normal table as

P(X ≤ x) = P

(X − µ

σ≤ x− µ

σ

)= P

(Y ≤ x− µ

σ

)= Φ

(x− µ

σ

),

where Y is a standard normal random variable.

The normal random variable is often used in signal processing and com-munications engineering to model noise and unpredictable distortions of signals.The following is a typical example.

Example 3.9. Signal Detection. A binary message is transmitted as a signalthat is either −1 or +1. The communication channel corrupts the transmission withadditive normal noise with mean µ = 0 and variance σ2. The receiver concludesthat the signal −1 (or +1) was transmitted if the value received is < 0 (or ≥ 0,respectively); see Fig. 3.11. What is the probability of error?

An error occurs whenever −1 is transmitted and the noise N is at least 1 sothat N + S = N − 1 ≥ 0, or whenever +1 is transmitted and the noise N is smaller

Page 167: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

20 General Random Variables Chap. 3

+1 if N + S > 0

-1 if N + S <0

Transmitter ReceiverNoisy ChannelSignal

S = +1 or -1

Normal zero-mean noise N

with variance σ2

N + S

0-1

Region of errorwhen a -1 istransmitted

0

Region of errorwhen a +1 istransmitted

1

Figure 3.11: The signal detection scheme of Example 3.9. The area of theshaded region gives the probability of error in the two cases where −1 and +1is transmitted.

than −1 so that N + S = N + 1 < 0. In the former case, the probability of error is

P(N ≥ 1) = 1 −P(N < 1) = 1 −P(

N − µ

σ<

1− µ

σ

)

= 1 − Φ(

1 − µ

σ

)= 1 − Φ

(1

σ

).

In the latter case, the probability of error is the same, by symmetry. The valueof Φ(1/σ) can be obtained from the normal table. For σ = 1, we have Φ(1/σ) =Φ(1) = 0.8413, and the probability of the error is 0.1587.

The normal random variable plays an important role in a broad range ofprobabilistic models. The main reason is that, generally speaking, it models wellthe additive effect of many independent factors, in a variety of engineering, phys-ical, and statistical contexts. Mathematically, the key fact is that the sum of alarge number of independent and identically distributed (not necessarily normal)random variables has an approximately normal CDF, regardless of the CDF ofthe individual random variables. This property is captured in the celebratedcentral limit theorem, which will be discussed in Chapter 7.

3.4 CONDITIONING ON AN EVENT

The conditional PDF of a continuous random variable X, conditioned on aparticular event A with P(A) > 0, is a function fX|A that satisfies

P(X ∈ B |A) =

B

fX|A(x) dx,

Page 168: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.4 Conditioning on an event 21

for any subset B of the real line. It is the same as an ordinary PDF, except thatit now refers to a new universe in which the event A is known to have occurred.

An important special case arises when we condition on X belonging to asubset A of the real line, with P(X ∈ A) > 0. We then have

P(X ∈ B |X ∈ A) =P(X ∈ B and X ∈ A)

P(X ∈ A)=

A∩B

fX(x) dx

P(X ∈ A).

This formula must agree with the earlier one, and therefore,†

fX|A(x |A) =

fX(x)

P(X ∈ A)if x ∈ A,

0 otherwise.

As in the discrete case, the conditional PDF is zero outside the conditioningset. Within the conditioning set, the conditional PDF has exactly the sameshape as the unconditional one, except that it is scaled by the constant factor1/P(X ∈ A). This normalization ensures that fX|A integrates to 1, which makesit a legitimate PDF; see Fig. 3.13.

x

fX(x)

a b

fX|A(x)

Figure 3.13: The unconditional PDF fX and the conditional PDF fX|A, whereA is the interval [a, b]. Note that within the conditioning event A, fX|A retainsthe same shape as fX , except that it is scaled along the vertical axis.

Example 3.10. The exponential random variable is memoryless. Alvingoes to a bus stop where the time T between two successive buses has an exponentialPDF with parameter λ. Suppose that Alvin arrives t secs after the preceding busarrival and let us express this fact with the event A = T > t. Let X be the timethat Alvin has to wait for the next bus to arrive. What is the conditional CDFFX|A(x |A)?

† We are using here the simpler notation fX|A(x) in place of fX|X∈A, which is

more accurate.

Page 169: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

22 General Random Variables Chap. 3

We have

P(X > x |A) = P(T > t + x | T > t)

=P(T > t + x and T > t)

P(T > t)

=P(T > t + x)

P(T > t)

=e−λ(t+x)

e−λt

= e−λx,

where we have used the expression for the CDF of an exponential random variablederived in Example 3.6.

Thus, the conditional CDF of X is exponential with parameter λ, regardlessthe time t that elapsed between the preceding bus arrival and Alvin’s arrival. Thisis known as the memorylessness property of the exponential. Generally, if we modelthe time to complete a certain operation by an exponential random variable X,this property implies that as long as the operation has not been completed, theremaining time up to completion has the same exponential CDF, no matter whenthe operation started.

For a continuous random variable, the conditional expectation is definedsimilar to the unconditional case, except that we now need to use the condi-tional PDF. We summarize the discussion so far, together with some additionalproperties in the table that follows.

Conditional PDF and Expectation Given an Event

• The conditional PDF fX|A of a continuous random variable X givenan event A with P(A) > 0, satisfies

P(X ∈ B |A) =

B

fX|A(x) dx.

• If A be a subset of the real line with P(X ∈ A) > 0, then

fX|A(x) =

fX(x)

P(X ∈ A)if x ∈ A,

0 otherwise,

and

P(X ∈ B |X ∈ A) =

B

fX|A(x) dx,

for any set B.

Page 170: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.4 Conditioning on an event 23

• The corresponding conditional expectation is defined by

E[X |A] =

∫ ∞

−∞xfX|A(x) dx.

• The expected value rule remains valid:

E[g(X) |A

]=

∫ ∞

−∞g(x)fX|A(x) dx.

• If A1, A2, . . . ,An are disjoint events with P(Ai) > 0 for each i, thatform a partition of the sample space, then

fX(x) =

n∑

i=1

P(Ai)fX|Ai(x)

(a version of the total probability theorem), and

E[X] =

n∑

i=1

P(Ai)E[X |Ai]

(the total expectation theorem). Similarly,

E[g(X)

]=

n∑

i=1

P(Ai)E[g(X) |Ai

].

To justify the above version of the total probability theorem, we use thetotal probability theorem from Chapter 1, to obtain

P(X ≤ x) =

n∑

i=1

P(Ai)P(X ≤ x |Ai).

This formula can be rewritten as∫ x

−∞fX(t) dt =

n∑

i=1

P(Ai)

∫ x

−∞fX|Ai

(t) dt.

We take the derivative of both sides, with respect to x, and obtain the desiredrelation

fX (x) =

n∑

i=1

P(Ai)fX|Ai(x).

Page 171: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

24 General Random Variables Chap. 3

If we now multiply both sides by x and then integrate from −∞ to ∞, we obtainthe total expectation theorem for continuous random variables.

The total expectation theorem can often facilitate the calculation of themean, variance, and other moments of a random variable, using a divide-and-conquer approach.

Example 3.11. Mean and Variance of a Piecewise Constant PDF. Supposethat the random variable X has the piecewise constant PDF

fX(x) =

1/3 if 0 ≤ x ≤ 1,2/3 if 1 < x ≤ 2,0 otherwise,

(see Fig. 3.14). Consider the events

A1 =X lies in the first interval [0, 1]

,

A2 =X lies in the second interval (1, 2]

.

We have from the given PDF,

P(A1) =

∫ 1

0

fX(x) dx =1

3, P(A2) =

∫ 2

1

fX(x)dx =2

3.

Furthermore, the conditional mean and second moment of X, conditioned on A1

and A2, are easily calculated since the corresponding conditional PDFs fX|A1and

fX|A2are uniform. We recall from Example 3.4 that the mean of a uniform random

variable on an interval [a, b] is (a + b)/2 and its second moment is (a2 + ab + b2)/3.Thus,

E[X |A1] =1

2, E[X |A2] =

3

2,

E[X2 |A1

]=

1

3, E

[X2 |A2

]=

7

3.

x1

fx(x)

2

1/3

2/3

Figure 3.14: Piecewise con-

stant PDF for Example 3.11.

Page 172: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.4 Conditioning on an event 25

We now use the total expectation theorem to obtain

E[X] = P(A1)E[X |A1] + P(A2)E[X |A2] =1

3· 1

2+

2

3· 3

2=

7

6,

E[X2] = P(A1)E[X2 |A1] + P(A2)E[X2 |A2] =1

3· 1

3+

2

3· 7

3=

15

9.

The variance is given by

var(X) = E[X2] −(E[X]

)2=

15

9− 49

36=

11

36.

Note that this approach to the mean and variance calculation is easily generalizedto piecewise constant PDFs with more than two pieces.

The next example illustrates a divide-and-conquer approach that uses thetotal probability theorem to calculate a PDF.

Example 3.12. The metro train arrives at the station near your home everyquarter hour starting at 6:00 AM. You walk into the station every morning between7:10 and 7:30 AM, with the time in this interval being a uniform random variable.What is the PDF of the time you have to wait for the first train to arrive?

x

fX(x)

7:10 7:15 7:30

fY|A(y)

y5

1/5

fY(y)

y

fY|B(y)

y15

1/15

5 15

1/10

1/20

(a) (b)

(c) (d)

Figure 3.15: The PDFs fX , fY |A, fY |B , and fY in Example 3.12.

The time of your arrival, denoted by X, is a uniform random variable on theinterval from 7:10 to 7:30; see Fig. 3.15(a). Let Y be the waiting time. We calculatethe PDF fY using a divide-and-conquer strategy. Let A and B be the events

A = 7:10 ≤ X ≤ 7:15 = you board the 7:15 train,

Page 173: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

26 General Random Variables Chap. 3

B = 7:15 < X ≤ 7:30 = you board the 7:30 train.

Conditioned on the event A, your arrival time is uniform on the interval from 7:10to 7:15. In that case, the waiting time Y is also uniform and takes values between0 and 5 minutes; see Fig. 3.15(b). Similarly, conditioned on B, Y is uniform andtakes values between 0 and 15 minutes; see Fig. 3.15(c). The PDF of Y is obtainedusing the total probability theorem,

fY (y) = P(A)fY |A(y) + P(B)fY |B(y),

and is shown in Fig. 3.15(d). In particular,

fY (y) =1

4· 1

5+

3

4· 1

15=

1

10, for 0 ≤ y ≤ 5,

and

fY (y) =1

4· 0 +

3

4· 1

15=

1

20, for 5 < y ≤ 15.

3.5 MULTIPLE CONTINUOUS RANDOM VARIABLES

We will now extend the notion of a PDF to the case of multiple random vari-ables. In complete analogy with discrete random variables, we introduce joint,marginal, and conditional PDFs. Their intuitive interpretation as well as theirmain properties parallel the discrete case.

We say that two continuous random variables associated with a commonexperiment are jointly continuous and can be described in terms of a jointPDF fX,Y , if fX,Y is a nonnegative function that satisfies

P((X,Y ) ∈ B

)=

∫ ∫

(x,y)∈B

fX,Y (x, y) dx dy,

for every subset B of the two-dimensional plane. The notation above meansthat the integration is carried over the set B. In the particular case where B isa rectangle of the form B = [a, b]× [c, d], we have

P(a ≤ X ≤ b, c ≤ Y ≤ d) =

∫ d

c

∫ b

a

fX,Y (x, y) dx dy.

Furthermore, by letting B be the entire two-dimensional plane, we obtain thenormalization property

∫ ∞

−∞

∫ ∞

−∞fX,Y (x, y) dx dy = 1.

Page 174: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.5 Multiple Continuous Random Variables 27

To interpret the PDF, we let δ be very small and consider the probabilityof a small rectangle. We have

P(a ≤ X ≤ a+δ, c ≤ Y ≤ c+δ) =

∫ c+δ

c

∫ a+δ

a

fX,Y (x, y) dx dy ≈ fX,Y (a, c) ·δ2,

so we can view fX,Y (a, c) as the “probability per unit area” in the vicinity of(a, c).

The joint PDF contains all conceivable probabilistic information on therandom variables X and Y , as well as their dependencies. It allows us to calculatethe probability of any event that can be defined in terms of these two randomvariables. As a special case, it can be used to calculate the probability of anevent involving only one of them. For example, let A be a subset of the real lineand consider the event X ∈ A. We have

P(X ∈ A) = P(X ∈ A and Y ∈ (−∞,∞)

)=

A

∫ ∞

−∞fX,Y (x, y) dy dx.

Comparing with the formula

P(X ∈ A) =

A

fX(x) dx,

we see that the marginal PDF fX of X is given by

fX(x) =

∫ ∞

−∞fX,Y (x, y) dy.

Similarly,

fY (y) =

∫ ∞

−∞fX,Y (x, y) dx.

Example 3.13. Two-Dimensional Uniform PDF. Romeo and Juliet have adate at a given time, and each will arrive at the meeting place with a delay between0 and 1 hour (recall the example given in Section 1.2). Let X and Y denote thedelays of Romeo and Juliet, respectively. Assuming that no pairs (x, y) in thesquare [0, 1] × [0, 1] are more likely than others, a natural model involves a jointPDF of the form

fX,Y (x, y) =

c if 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1,0 otherwise,

where c is a constant. For this PDF to satisfy the normalization property

∫ ∞

−∞

∫ ∞

−∞fX,Y (x, y)dx dy =

∫ 1

0

∫ 1

0

c dx dy = 1,

Page 175: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

28 General Random Variables Chap. 3

we must have

c = 1.

This is an example of a uniform PDF on the unit square. More generally,let us fix some subset S of the two-dimensional plane. The corresponding uniformjoint PDF on S is defined to be

fX,Y (x, y) =

1

area of Sif (x, y) ∈ S,

0 otherwise.

For any set A ⊂ S, the probability that the experimental value of (X,Y ) lies in Ais

P((X,Y ) ∈ A

)=

∫ ∫

(x,y)∈A

fX,Y (x, y) dx dy =1

area of S

∫ ∫

(x,y)∈A∩S

dx dy =area of A ∩ S

area of S.

Example 3.14. We are told that the joint PDF of the random variables X and Yis a constant c on the set S shown in Fig. 3.16 and is zero outside. Find the valueof c and the marginal PDFs of X and Y .

The area of the set S is equal to 4 and, therefore, fX,Y (x, y) = c = 1/4, for(x, y) ∈ S. To find the marginal PDF fX(x) for some particular x, we integrate(with respect to y) the joint PDF over the vertical line corresponding to that x.The resulting PDF is shown in the figure. We can compute fY similarly.

x

fX(x)

fY(y)

y

S

x

1/4

3/4

y

1/4

1/2

1 3

4

2

2

1

3

Figure 3.16: The joint PDF in Example 3.14 and the resulting marginalPDFs.

Page 176: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.5 Multiple Continuous Random Variables 29

Example 3.15. Buffon’s Needle. This is a famous example, which marksthe origin of the subject of geometrical probability, that is, the analysis of thegeometrical configuration of randomly placed objects.

A surface is ruled with parallel lines, which are at distance d from each other(see Fig. 3.17). Suppose that we throw a needle of length l on the surface at random.What is the probability that the needle will intersect one of the lines?

x

d

θ

Figure 3.17: Buffon’s needle. The

length of the line segment between the

midpoint of the needle and the point

of intersection of the axis of the needle

with the closest parallel line is x/ sin θ.

The needle will intersect the closest par-

allel line if and only if this length is less

than l/2.

We assume here that l < d so that the needle cannot intersect two linessimultaneously. Let X be the distance from the midpoint of the needle to thenearest of the parallel lines, and let Θ be the acute angle formed by the axis of theneedle and the parallel lines (see Fig. 3.17). We model the pair of random variables(X,Θ) with a uniform joint PDF over the rectangle [0, d/2]× [0, π/2], so that

fX,Θ(x, θ) =

4/(πd) if x ∈ [0, d/2] and θ ∈ [0, π/2],0 otherwise.

As can be seen from Fig. 3.17, the needle will intersect one of the lines if andonly if

X ≤ l

2sin Θ,

so the probability of intersection is

P(X ≤ (l/2) sinΘ

)=

∫ ∫

x≤(l/2) sin θ

fX,Θ(x, θ)dx dθ

=4

πd

∫ π/2

0

∫ (l/2) sin θ

0

dx dθ

=4

πd

∫ π/2

0

l

2sin θ dθ

=2l

πd(− cos θ)

∣∣∣π/2

0

=2l

πd.

The probability of intersection can be empirically estimated, by repeating the ex-periment a large number of times. Since it is equal to 2l/πd, this provides us witha method for the experimental evaluation of π.

Page 177: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

30 General Random Variables Chap. 3

Expectation

If X and Y are jointly continuous random variables, and g is some function, thenZ = g(X, Y ) is also a random variable. We will see in Section 3.6 methods forcomputing the PDF of Z, if it has one. For now, let us note that the expectedvalue rule is still applicable and

E[g(X,Y )

]=

∫ ∞

−∞

∫ ∞

−∞g(x, y)fX,Y (x, y) dx dy.

As an important special case, for any scalars a, b, we have

E[aX + bY ] = aE[X ] + bE[Y ].

Conditioning One Random Variable on Another

Let X and Y be continuous random variables with joint PDF fX,Y . For anyfixed y with fY (y) > 0, the conditional PDF of X given that Y = y, is definedby

fX|Y (x | y) =fX,Y (x, y)

fY (y).

This definition is analogous to the formula pX|Y = pX,Y /pY for the discrete case.When thinking about the conditional PDF, it is best to view y as a fixed

number and consider fX|Y (x | y) as a function of the single variable x. As afunction of x, the conditional PDF fX|Y (x | y) has the same shape as the jointPDF fX,Y (x, y), because the normalizing factor fY (y) does not depend on x; seeFig. 3.18. Note that the normalization ensures that

∫ ∞

−∞fX|Y (x | y) dx = 1,

so for any fixed y, fX|Y (x | y) is a legitimate PDF.

x

fX|Y(x|1.5)

y

S

1 3

4

2

2

1

3x

x

x 1 32

fX|Y(x|2.5)

fX|Y(x|3.5)

1

1

1/2

Figure 3.18: Visualization of the conditional PDF fX|Y (x | y). Let X, Y have ajoint PDF which is uniform on the set S. For each fixed y, we consider the jointPDF along the slice Y = y and normalize it so that it integrates to 1.

Page 178: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.5 Multiple Continuous Random Variables 31

Example 3.16. Circular Uniform PDF. John throws a dart at a circulartarget of radius r (see Fig. 3.19). We assume that he always hits the target, andthat all points of impact (x, y) are equally likely, so that the joint PDF of therandom variables X and Y is uniform. Following Example 3.13, and since the areaof the circle is πr2, we have

fX,Y (x, y) =

1

area of the circleif (x, y) is in the circle,

0 otherwise,

=

1

πr2if x2 + y2 ≤ r2,

0 otherwise.

x

y

r Figure 3.19: Circular target for

Example 3.16.

To calculate the conditional PDF fX|Y (x | y), let us first calculate the marginalPDF fY (y). For |y| > r, it is zero. For |y| ≤ r, it can be calculated as follows:

fY (y) =

∫ ∞

−∞fX,Y (x, y) dx

=1

πr2

x2+y2≤r2

dx

=1

πr2

∫ √r2−y2

−√

r2−y2dx

=2

πr2

√r2 − y2.

Note that the marginal fY (y) is not a uniform PDF.

Page 179: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

32 General Random Variables Chap. 3

The conditional PDF is

fX|Y (x | y) =fX,Y (x, y)

fY (y)

=

1

πr2

2

πr2

√r2 − y2

=1

2√

r2 − y2.

Thus, for a fixed value of y, the conditional PDF fX|Y is uniform.

To interpret the conditional PDF, let us fix some small positive numbersδ1 and δ2, and condition on the event B = y ≤ Y ≤ y + δ2. We have

P(x ≤ X ≤ x + δ1 | y ≤ Y ≤ y + δ2) =P(x ≤ X ≤ x + δ1 and y ≤ Y ≤ y + δ2)

P(y ≤ Y ≤ y + δ2)

≈ fX,Y (x, y)δ1δ2

fY (y)δ2= fX|Y (x | y)δ1.

In words, fX|Y (x | y)δ1 provides us with the probability that X belongs in asmall interval [x, x + δ1], given that Y belongs in a small interval [y, y + δ2].Since fX|Y (x | y)δ1 does not depend on δ2, we can think of the limiting casewhere δ2 decreases to zero and write

P(x ≤ X ≤ x + δ1 | Y = y) ≈ fX|Y (x | y)δ1, (δ1 small),

and, more generally,

P(X ∈ A | Y = y) =

A

fX|Y (x | y) dx.

Conditional probabilities, given the zero probability event Y = y, were leftundefined in Chapter 1. But the above formula provides a natural way of definingsuch conditional probabilities in the present context. In addition, it allows us toview the conditional PDF fX|Y (x | y) (as a function of x) as a description of theprobability law of X, given that the event Y = y has occurred.

As in the discrete case, the conditional PDF fX|Y , together with themarginal PDF fY are sometimes used to calculate the joint PDF. Furthermore,this approach can be also used for modeling: instead of directly specifying fX,Y ,it is often natural to provide a probability law for Y , in terms of a PDF fY , andthen provide a conditional probability law fX|Y (x, y) for X, given any possiblevalue y of Y .

Example 3.17. Let X be exponentially distributed with mean 1. Once weobserve the experimental value x of X, we generate a normal random variable Ywith zero mean and variance x + 1. What is the joint PDF of X and Y ?

Page 180: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.5 Multiple Continuous Random Variables 33

We have fX(x) = e−x, for x ≥ 0, and

fY |X(y |x) =1√

2π(x + 1)e−y2/2(x+1)

.

Thus,

fX,Y (x, y) = fX(x)fY |X(y | x) = e−x 1√2π(x + 1)

e−y2/2(x+1),

for all x ≥ 0 and all y.

Having defined a conditional probability law, we can also define a corre-sponding conditional expectation by letting

E[X |Y = y] =

∫ ∞

−∞xfX|Y (x | y) dx.

The properties of (unconditional) expectation carry though, with the obviousmodifications, to conditional expectation. For example the conditional versionof the expected value rule

E[g(X) | Y = y] =

∫ ∞

−∞g(x)fX|Y (x | y) dx

remains valid.

Summary of Facts About Multiple Continuous Random Variables

Let X and Y be jointly continuous random variables with joint PDF fX,Y .

• The joint, marginal, and conditional PDFs are related to each otherby the formulas

fX,Y (x, y) = fY (y)fX|Y (x | y),

fX (x) =

∫ ∞

−∞fY (y)fX |Y (x | y) dy.

The conditional PDF fX|Y (x | y) is defined only for those y for whichfY (y) > 0.

Page 181: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

34 General Random Variables Chap. 3

• They can be used to calculate probabilities:

P((X, Y ) ∈ B

)=

∫ ∫

(x,y)∈B

fX,Y (x, y) dx dy,

P(X ∈ A) =

A

fX(x) dx,

P(X ∈ A | Y = y) =

A

fX|Y (x | y) dx.

• They can also be used to calculate expectations:

E[g(X)] =

∫g(x)fX(x) dx,

E[g(X,Y )

]=

∫ ∫g(x, y)fX,Y (x, y) dx dy,

E[g(X) | Y = y

]=

∫g(x)fX|Y (x | y) dx,

E[g(X, Y ) | Y = y

]=

∫g(x, y)fX|Y (x | y) dx.

• For any event A, we have the following version of the total probabilitytheorem:

P(A) =

∫P(A | Y = y)fY (y) dy.

• We have the following versions of the total expectation theorem:

E[X ] =

∫E[X | Y = y]fY (y) dy,

E[g(X)

]=

∫E

[g(X) | Y = y]fY (y) dy,

E[g(X, Y )

]=

∫E

[g(X, Y ) |Y = y]fY (y) dy.

To justify the first version of the total expectation theorem, we observethat

∫E[X | Y = y]fY (y) dy =

∫ [∫xfX|Y (x | y) dx

]fY (y) dy

Page 182: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.5 Multiple Continuous Random Variables 35

=

∫ ∫xfX|Y (x | y)fY (y) dx dy

=

∫ ∫xfX,Y (x, y) dx dy

=

∫x

[∫fX,Y (x, y) dy

]dx

=

∫xfX(x) dx

= E[X ].

The other two versions are justified similarly. The total probability equationP(A) =

∫P(A |Y = y)fY (y) dy follows from the total expectation theorem by

letting X be the random variable that takes the value 1 if X ∈ A and the value0 otherwise, since then E[X] = P(A) and E[X | Y = y] = P(A | Y = y).

Inference and the Continuous Bayes’ Rule

In many situations, we have a model of an underlying but unobserved phe-nomenon, represented by a random variable X with PDF fX , and we makenoisy measurements Y . The measurements are supposed to provide informationabout X and are modeled in terms of a conditional PDF fY |X . For example, ifY is the same as X, but corrupted by zero-mean normally distributed noise, onewould let the conditional PDF fY |X(y |x) of Y , given that X = x, be normalwith mean equal to x. Once the experimental value of Y is measured, whatinformation does this provide on the unknown value of X?

This setting is similar to that encountered in Section 1.4, when we intro-duced the Bayes rule and used it to solve inference problems. The only differenceis that we are now dealing with continuous random variables.

Note that the information provided by the event Y = y is described bythe conditional PDF fX|Y (x | y). It thus suffices to evaluate the latter PDF. Acalculation analogous to the original derivation of the Bayes’ rule, based on theformulas fXfY |X = fX,Y = fY fX|Y , yields

fX|Y (x | y) =fX (x)fY |X(y |x)

fY (y)=

fX(x)fY |X(y | x)∫fX (t)fY |X (y | t)dt

,

which is the desired formula.

Example 3.18. A lightbulb produced by the General Illumination Company isknown to have an exponentially distributed lifetime Y . However, the company hasbeen experiencing quality control problems. On any given day, the parameter λ ofthe PDF of Y is actually a random variable, uniformly distributed in the interval[0, 1/2]. We test a lightbulb and record the experimental value y of its lifetime.What can we say about the underlying parameter λ?

Page 183: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

36 General Random Variables Chap. 3

We model the parameter λ as a random variable X, with a uniform distri-bution. All available information about X is contained in the conditional PDFfX|X(x | y). We view y as a constant (equal to the observed value of Y ) and con-centrate on the dependence of the PDF on x. Note that fX(x) = 2, for 0 ≤ x ≤ 1/2.By the continuous Bayes rule, we have

fX|Y (x | y) =2xe−xy

∫ 1/2

02te−tydt

, for 0 ≤ x ≤ 1

2.

In some cases, the unobserved phenomenon is inherently discrete. Forexample, if a binary signal is observed in the presence of noise with a normaldistribution. Or if a medical diagnosis is to be made on the basis of continuousmeasurements like temperature and blood counts. In such cases, a somewhatdifferent version of Bayes’ rule applies.

Let X be a discrete random variable that takes values in a finite set1, . . . , n and which represents the different discrete possibilities for the un-observed phenomenon of interest. The PMF pX of X is assumed to be known.Let Y be a continuous random variable which, for any given value x, is describedby a conditional PDF fY |X(y | x). We are interested in the conditional PMF ofX given the experimental value y of Y .

Instead of working with conditioning event Y = y which has zero proba-bility, let us instead condition on the event y ≤ Y ≤ y + δ, where δ is a smallpositive number, and then take the limit as δ tends to zero. We have, using theBayes rule

P(X = x |Y = y) ≈ P(X = x | y ≤ Y ≤ y + δ)

=pX(x)P(y ≤ Y ≤ y + δ |X = x)

P(y ≤ Y ≤ y + δ)

≈pX(x)fY |X (y | x)δ

fY (y)δ

=pX(x)fY |X (y | x)

fY (y).

The denominator can be evaluated using a version of the total probability theo-rem introduced in Section 3.4. We have

fY (y) =

n∑

i=1

pX(i)fY |X(y | i).

Example 3.19. Let us revisit the signal detection problem considered in 3.9. Asignal S is transmitted and we are given that P(S = 1) = p and P(S = −1) = 1−p.

Page 184: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.5 Multiple Continuous Random Variables 37

The received signal is Y = N +S, where N is zero mean normal noise, with varianceσ2, independent of S. What is the probability that S = 1, as a function of theobserved value y of Y ?

Conditioned on S = s, the random variable Y has a normal distribution withmean s and variance σ2. Applying the formula developed above, we obtain

P(S = 1 | Y = y) =pS(1)fY |S(y | 1)

fY (y)=

p√2π σ

e−(y−1)2/2σ2

p√2π σ

e−(y−1)2/2σ2+ 1−p√

2π σe−(y+1)2/2σ2 .

Independence

In full analogy with the discrete case, we say that two continuous random vari-ables X and Y are independent if their joint PDF is the product of the marginalPDFs:

fX,Y (x, y) = fX(x)fY (y), for all x, y.

Comparing with the formula fX,Y (x, y) = fX|Y (x | y)fY (y), we see that inde-pendence is the same as the condition

fX|Y (x | y) = fX(x), for all x and all y with fY (y) > 0,

or, symmetrically,

fY |X(y | x) = fY (y), for all y and all x with fX(x) > 0.

If X and Y are independent, then any two events of the form X ∈ A andY ∈ B are independent. Indeed,

P(X ∈ A and Y ∈ B) =

x∈A

y∈B

fX,Y (x, y) dy dx

=

x∈A

y∈B

fX (x)fY (y) dy dx

=

x∈A

fX(x) dx

y∈B

fY (y) dy

= P(X ∈ A)P(Y ∈ B).

A converse statement is also true; see the end-of-chapter problems.A calculation similar to the discrete case shows that if X and Y are inde-

pendent, thenE[g(X)h(Y )] = E[g(X)]E[h(Y )],

for any two functions g and h. Finally, the variance of the sum of independentrandom variables is again equal to the sum of the variances.

Page 185: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

38 General Random Variables Chap. 3

Independence of Continuous Random Variables

Suppose that X and Y are independent, that is,

fX,Y (x, y) = fX(x)fY (y), for all x, y.

We then have the following properties.

• The random variables g(X) and h(Y ) are independent, for any func-tions g and h.

• We haveE[XY ] = E[X]E[Y ],

and, more generally,

E[g(X)h(Y )

]= E

[g(X)

]E

[h(Y )

],

• We havevar(X + Y ) = var(X) + var(Y ).

Joint CDFs

If X and Y are two random variables associated with the same experiment, wedefine their joint CDF by

FX,Y (x, y) = P(X ≤ x, Y ≤ y).

As in the case of one random variable, the advantage of working with the CDFis that it applies equally well to discrete and continuous random variables. Inparticular, if X and Y are described by a joint PDF fX,Y , then

FX,Y (x, y) = P(X ≤ x, Y ≤ y) =

∫ x

−∞

∫ y

−∞fX,Y (s, t) ds dt.

Conversely, the PDF can be recovered from the PDF by differentiating:

fX,Y (x, y) =∂2FX,Y

∂x∂y(x, y).

Example 3.20. Let X and Y be described by a uniform PDF on the unit square.The joint CDF is given by

FX,Y (x, y) = P(X ≤ x, Y ≤ y) = xy, for 0 ≤ x, y ≤ 1.

Page 186: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.6 Derived Distributions 39

We then verify that

∂2FX,Y

∂x∂y(x, y) =

∂2(xy)

∂x∂y(x, y) = 1 = fX,Y (x, y),

for all (x, y) in the unit square.

More than Two Random Variables

The joint PDF of three random variables X, Y , and Z is defined in analogy withthe above. For example, we have

P((X, Y, Z) ∈ B

)=

∫ ∫ ∫

(x,y,z)∈B

fX,Y,Z(x, y, z) dx dy dz,

for any set B. We also have relations such as

fX,Y (x, y) =

∫fX,Y,Z(x, y, z) dz,

and

fX(x) =

∫ ∫fX,Y,Z(x, y, z) dy dz.

One can also define conditional PDFs by formulas such as

fX,Y |Z(x, y | z) =fX,Y,Z(x, y, z)

fZ(z), for fZ(z) > 0,

fX|Y,Z(x | y, z) =fX,Y,Z(x, y, z)

fY,Z (y, z), for fY,Z(y, z) > 0.

There is an analog of the multiplication rule:

fX,Y,Z(x, y, z) = fX|Y,Z(x | y, z)fY |Z(y | z)fZ(z).

Finally, we say that the three random variables X, Y , and Z are independent if

fX,Y,Z(x, y, z) = fX (x)fY (y)fZ(z), for all x, y, z.

The expected value rule for functions takes the form

E[g(X, Y, Z)

]=

∫ ∫ ∫g(x, y, z)fX,Y,Z (x, y, z) dx dy dz,

and if g is linear and of the form aX + bY + cZ, then

E[aX + bY + cZ] = aE[X] + bE[Y ] + cE[Z].

Furthermore, there are obvious generalizations of the above to the case of morethan three random variables. For example, for any random variables X1,X2, . . . , Xn

and any scalars a1, a2, . . . , an, we have

E[a1X1 + a2X2 + · · ·+ anXn] = a1E[X1] + a2E[X2] + · · ·+ anE[Xn].

Page 187: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

40 General Random Variables Chap. 3

3.6 DERIVED DISTRIBUTIONS

We have seen that the mean of a function Y = g(X) of a continuous randomvariable X , can be calculated using the expected value rule

E[Y ] =

∫ ∞

−∞g(x)fX(x) dx,

without first finding the PDF fY of Y . Still, in some cases, we may be interestedin an explicit formula for fY . Then, the following two-step approach can beused.

Calculation of the PDF of a Function Y = g(X) of a ContinuousRandom Variable X

1. Calculate the CDF FY of Y using the formula

FY (y) = P(g(X) ≤ y

)=

x | g(x)≤yfX (x) dx.

2. Differentiate to obtain the PDF of Y :

fY (y) =dFY

dy(y).

Example 3.21. Let X be uniform on [0, 1]. Find the PDF of Y =√

X. Notethat Y takes values between 0 and 1. For every y ∈ [0, 1], we have

FY (y) = P(Y ≤ y) = P(√

X ≤ y) = P(X ≤ y2) = y2, 0 ≤ y ≤ 1.

We then differentiate and obtain

fY (y) =dFY

dy(y) =

d(y2)

dy= 2y, 0 ≤ y ≤ 1.

Outside the range [0, 1], the CDF FY (y) is constant, with FY (y) = 0 for y ≤ 0, andFY (y) = 1 for y ≥ 1. By differentiating, we see that fY (y) = 0 for y outside [0, 1].

Example 3.22. John Slow is driving from Boston to the New York area, a distanceof 180 miles at a constant speed, whose value is uniformly distributed between 30and 60 miles per hour. What is the PDF of the duration of the trip?

Page 188: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.6 Derived Distributions 41

Let X be the speed and let Y = g(X) be the trip duration:

g(X) =180

X.

To find the CDF of Y , we must calculate

P(Y ≤ y) = P(

180

X≤ y

)= P

(180

y≤ X

).

We use the given uniform PDF of X, which is

fX(x) =

1/30 if 30 ≤ x ≤ 60,0 otherwise,

and the corresponding CDF, which is

FX(x) =

0 if x ≤ 30,(x− 30)/30 if 30 ≤ x ≤ 60,1 if 60 ≤ x.

Thus,

FY (y) = P

(180

y≤ X

)

= 1 − FX

(180

y

)

=

0 if y ≤ 180/60,

1 −

180

y− 30

30if 180/60 ≤ y ≤ 180/30,

1 if 180/30 ≤ y,

=

0 if y ≤ 3,2− (6/y) if 3 ≤ y ≤ 6,1 if 6 ≤ y,

(see Fig. 3.20). Differentiating this expression, we obtain the PDF of Y :

fY (y) =

0 if y ≤ 3,6/y2 if 3 ≤ y ≤ 6,0 if 6 ≤ y.

Example 3.23. Let Y = g(X) = X2, where X is a random variable with knownPDF. For any y ≥ 0, we have

FY (y) = P(Y ≤ y)

= P(X2 ≤ y)

= P(−√y ≤ X ≤ √y)

= FX(√

y) − FX(−√y),

and therefore, by differentiating and using the chain rule,

fY (y) =1

2√

yfX(

√y) +

1

2√

yfX(−√y), y ≥ 0.

Page 189: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

42 General Random Variables Chap. 3

x

PDF fX(x)

30 60

130

x

CDF FX(x)

1

30 60

y

PDF fY(y)

3 6 y

CDF FY(y)

1

3 6

Figure 3.20: The calculation of the PDF of Y = 180/X in Example 3.22. Thearrows indicate the flow of the calculation.

The Linear Case

An important case arises when Y is a linear function of X. See Fig. 3.21 for agraphical interpretation.

The PDF of a Linear Function of a Random Variable

Let X be a continuous random variable with PDF fX , and let

Y = aX + b,

for some scalars a 6= 0 and b. Then,

fY (y) =1

|a|fX

(y − b

a

).

To verify this formula, we use the two-step procedure. We only show the

Page 190: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.6 Derived Distributions 43

fXfaX

−1 2

faX+b

3 4 9−2

Figure 3.21: The PDF of aX + b in terms of the PDF of X. In this figure,a = 2 and b = 5. As a first step, we obtain the PDF of aX. The range of Y iswider than the range of X, by a factor of a. Thus, the PDF fX must be stretched(scaled horizontally) by this factor. But in order to keep the total area under thePDF equal to 1, we need to scale the PDF (vertically) by the same factor a. Therandom variable aX + b is the same as aX except that its values are shifted byb. Accordingly, we take the PDF of aX and shift it (horizontally) by b. The endresult of these operations is the PDF of Y = aX + b and is given mathematicallyby

fY (y) =1

|a|fX

(y − b

a

).

If a were negative, the procedure would be the same except that thePDF of X would first need to be reflected around the vertical axis (“flipped”)yielding f−X . Then a horizontal and vertical scaling (by a factor of |a| and 1/|a|,respectively) yields the PDF of −|a|X = aX. Finally, a horizontal shift of b wouldagain yield the PDF of aX + b.

steps for the case where a > 0; the case a < 0 is similar. We have

FY (y) = P(Y ≤ y)

= P(aX + b ≤ y)

= P

(X ≤ y − b

a

)

= FX

(y − b

a

).

We now differentiate this equality and use the chain rule, to obtain

fY (y) =dFY

dy(y) =

1

a· dFX

dx

(y − b

a

)=

1

a· fX

(y − b

a

).

Example 3.24. A linear function of an exponential random variable.Suppose that X is an exponential random variable with PDF

fX(x) =

λe−λx if x ≥ 0,0 otherwise,

Page 191: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

44 General Random Variables Chap. 3

where λ is a positive parameter. Let Y = aX + b. Then,

fY (y) =

λ

|a|e−λ(y−b)/a if (y − b)/a ≥ 0,

0 otherwise.

Note that if b = 0 and a > 0, then Y is an exponential random variable withparameter λ/a. In general, however, Y need not be exponential. For example, ifa < 0 and b = 0, then the range of Y is the negative real axis.

Example 3.25. A linear function of a normal random variable is normal.Suppose that X is a normal random variable with mean µ and variance σ2, and letY = aX + b, where a and b are some scalars. We have

fX(x) =1√2π σ

e−(x−µ)2/2σ2.

Therefore,

fY (y) =1

|a|fX

(y − b

a

)

=1

|a|1√2π σ

e−((y−b)/a)−µ)2/2σ2

=1√

2π |a|σe−(y−b−aµ)2/2a2σ2

.

We recognize this as a normal PDF with mean aµ + b and variance a2σ2. Inparticular, Y is a normal random variable.

The Monotonic Case

The calculation and the formula for the linear case can be generalized tothe case where g is a monotonic function. Let X be a continuous random variableand suppose that its range is contained in a certain interval I , in the sense thatfX (x) = 0 for x /∈ I . We consider the random variable Y = g(X), and assumethat g is strictly monotonic over the interval I . That is, either

(a) g(x) < g(x′) for all x, x′ ∈ I satisfying x < x′ (monotonically increasingcase), or

(b) g(x) > g(x′) for all x, x′ ∈ I satisfying x < x′ (monotonically decreasingcase).

Furthermore, we assume that the function g is differentiable. Its derivativewill necessarily be nonnegative in the increasing case and nonpositive in thedecreasing case.

Page 192: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.6 Derived Distributions 45

An important fact is that a monotonic function can be “inverted” in thesense that there is some function h, called the inverse of g, such that for allx ∈ I , we have y = g(x) if and only if x = h(y). For example, the inverse of thefunction g(x) = 180/x considered in Example 3.22 is h(y) = 180/y, because wehave y = 180/x if and only if x = 180/y. Other such examples of pairs of inversefunctions include

g(x) = ax + b, h(y) =y − b

a,

where a and b are scalars with a 6= 0 (see Fig. 3.22), and

g(x) = eax, h(y) =ln y

a,

where a is a nonzero scalar.

0

h(y) =

x

y

Slope ab

0

g(x) = ax + b

x

yb

Slope 1/a

y - ba

0 x

y

0

g(x)

x

y

h(y) y = g(x)

x = h(y)

Figure 3.22: A monotonically increasing function g (on the left) and its inverse(on the right). Note that the graph of h has the same shape as the graph of g,except that it is rotated by 90 degrees and then reflected (this is the same asinterchanging the x and y axes).

For monotonic functions g, the following is a convenient analytical formulafor the PDF of the function Y = g(X).

Page 193: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

46 General Random Variables Chap. 3

PDF Formula for a Monotonic Function of a Continuous RandomVariable

Suppose that g is monotonic and that for some function h and all x in therange I of X we have

y = g(x) if and only if x = h(y).

Assume that h has first derivative (dh/dy)(y). Then the PDF of Y in theregion where fY (y) > 0 is given by

fY (y) = fX

(h(y)

) ∣∣∣∣dh

dy(y)

∣∣∣∣ .

For a verification of the above formula, assume first that g is monotonicallyincreasing. Then, we have

FY (y) = P(g(X) ≤ y

)= P

(X ≤ h(y)

)= FX

(h(y)

),

where the second equality can be justified using the monotonically increasingproperty of g (see Fig. 3.23). By differentiating this relation, using also thechain rule, we obtain

fY (y) =dFY

dy(y) = fX

(h(y)

)dh

dy(y).

Because g is monotonically increasing, h is also monotonically increasing, so itsderivative is positive:

dh

dy(y) =

∣∣∣∣dh

dy(y)

∣∣∣∣ .

This justifies the PDF formula for a monotonically increasing function g. Thejustification for the case of monotonically decreasing function is similar: wedifferentiate instead the relation

FY (y) = P(g(X) ≤ y

)= P

(X ≥ h(y)

)= 1− FX

(h(y)

),

and use the chain rule.There is a similar formula involving the derivative of g, rather than the

derivative of h. To see this, differentiate the equality g(h(y)

)= y, and use the

chain rule to obtaindg

dh

(h(y)

)· dh

dy(y) = 1.

Page 194: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.6 Derived Distributions 47

Let us fix some x and y that are related by g(x) = y, which is the same ash(y) = x. Then,

dg

dx(x) · dh

dy(y) = 1,

which leads to

fY (y) = fX(x)/ ∣∣∣∣

dg

dx(x)

∣∣∣∣ .

x

y= g(x)

y

h(y ) x

y

h(y )Event X < h(Y) Event X >h(Y)

y= g(x)

Figure 3.23: Calculating the probability P(g(X) ≤ y

). When g is monotonically

increasing (left figure), the event g(X) ≤ y is the same as the event X ≤ h(y).When g is monotonically decreasing (right figure), the event g(X) ≤ y is thesame as the event X ≥ h(y).

Example 3.22. (Continued) To check the PDF formula, let us apply it tothe problem of Example 3.22. In the region of interest, x ∈ [30, 60], we haveh(y) = 180/y, and

dFX

dh

(h(y)

)=

1

30,

∣∣∣∣dh

dy(y)

∣∣∣∣ =180

y2.

Thus, in the region of interest y ∈ [3, 6], the PDF formula yields

fY (y) = fX

(h(y)

) ∣∣∣∣dh

dy(y)

∣∣∣∣ =1

30· 180

y2=

6

y2,

consistently with the expression obtained earlier.

Example 3.26. Let Y = g(X) = X2, where X is a continuous uniform randomvariable in the interval (0, 1]. Within this interval, g is monotonic, and its inverse

Page 195: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

48 General Random Variables Chap. 3

is h(y) =√

y. Thus, for any y ∈ (0, 1], we have

∣∣∣∣dh

dy(y)

∣∣∣∣ =1

2√

y, fX(

√y) = 1,

and

fY (y) =

1

2√

yif y ∈ (0, 1],

0 otherwise.

We finally note that if we interpret PDFs in terms of probabilities of smallintervals, the content of our formulas becomes pretty intuitive; see Fig. 3.24.

Functions of Two Random Variables

The two-step procedure that first calculates the CDF and then differentiates toobtain the PDF also applies to functions of more than one random variable.

Example 3.27. Two archers shoot at a target. The distance of each shot fromthe center of the target is uniformly distributed from 0 to 1, independently of theother shot. What is the PDF of the distance of the losing shot from the center?

Let X and Y be the distances from the center of the first and second shots,respectively. Let also Z be the distance of the losing shot:

Z = maxX, Y .

We know that X and Y are uniformly distributed over [0, 1], so that for all z ∈ [0, 1],we have

P(X ≤ z) = P(Y ≤ z) = z.

Thus, using the independence of X and Y , we have for all z ∈ [0, 1],

FZ(z) = P(maxX,Y ≤ z

)

= P(X ≤ z, Y ≤ z)

= P(X ≤ z)P(Y ≤ z)

= z2.

Differentiating, we obtain

fZ(z) =

2z if 0 ≤ z ≤ 1,0 otherwise.

Example 3.28. Let X and Y be independent random variables that are uniformlydistributed on the interval [0, 1]. What is the PDF of the random variable Z =Y/X?

Page 196: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.6 Derived Distributions 49

x

g(x)

y

[x, x+δ1]

[y, y+δ2]

slope dg

dx(x)

Figure 3.24: Illustration of the PDF formula for a monotonically increasingfunction g. Consider an interval [x, x + δ1], where δ1 is a small number. Underthe mapping g, the image of this interval is another interval [y, y + δ2]. Since(dg/dx)(x) is the slope of g, we have

δ2

δ1≈ dg

dx(x),

or in terms of the inverse function,

δ1

δ2≈ dh

dy(y),

We now note that the event x ≤ X ≤ x+ δ1 is the same as the event y ≤ Y ≤y + δ2. Thus,

fY (y)δ2 ≈ P(y ≤ Y ≤ y + δ2)

= P(x ≤ X ≤ x + δ1)

≈ fX(x)δ1.

We move δ1 to the left-hand side and use our earlier formula for the ratio δ2/δ1,to obtain

fY (y)dg

dx(x) = fX (x).

Alternatively, if we move δ2 to the right-hand side and use the formula for δ1/δ2,we obtain

fY (y) = fX

(h(y)

)· dh

dy(y).

We will find the PDF of Z by first finding its CDF and then differentiating.We consider separately the cases 0 ≤ z ≤ 1 and z > 1. As shown in Fig. 3.25, wehave

FZ(z) = P(

Y

X≤ z

)=

z/2 if 0 ≤ z ≤ 1,1− 1/(2z) if z > 1,0 otherwise.

Page 197: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

50 General Random Variables Chap. 3

By differentiating, we obtain

fZ(z) =

1/2 if 0 ≤ z ≤ 1,1/(2z2) if z > 1,0 otherwise.

z

0

Slope z

x

y

0

Slope z

x

y z

1

1

1

1

1

Figure 3.25: The calculation of the CDF of Z = Y/X in Example 3.28. Thevalue P(Y/X ≤ z) is equal to the shaded subarea of the unit square. The figureon the left deals with the case where 0 ≤ z ≤ 1 and the figure on the right refersto the case where z > 1.

Example 3.29. Romeo and Juliet have a date at a given time, and each, inde-pendently, will be late by an amount of time that is exponentially distributed withparameter λ. What is the PDF of the difference between their times of arrival?

Let us denote by X and Y the amounts by which Romeo and Juliet are late,respectively. We want to find the PDF of Z = X − Y , assuming that X and Y areindependent and exponentially distributed with parameter λ. We will first calculatethe CDF FZ(z) by considering separately the cases z ≥ 0 and z < 0 (see Fig. 3.26).

For z ≥ 0, we have (see the left side of Fig. 3.26)

FZ(z) = P(X − Y ≤ z)

= 1 −P(X − Y > z)

= 1 −∫ ∞

0

(∫ ∞

z+y

fX,Y (x, y) dx

)dy

= 1 −∫ ∞

0

λe−λy

(∫ ∞

z+y

λe−λx dx

)dy

= 1 −∫ ∞

0

λe−λye−λ(z+y) dy

= 1 − e−λz

∫ ∞

0

λe−2λy dy

= 1 − 1

2e−λz

.

Page 198: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 51

z 0 z 0

Line x - y = z Line x - y = z

x

y

x

y

Figure 3.26: The calculation of the CDF of Z = X−Y in Example 3.29. Toobtain the value P(X − Y > z) we must integrate the joint PDF fX,Y (x, y)over the shaded area in the above figures, which correspond to z ≥ 0 (leftside) and z < 0 (right side).

For the case z < 0, we can use a similar calculation, but we can also argueusing symmetry. Indeed, the symmetry of the situation implies that the randomvariables Z = X − Y and −Z = Y −X have the same distribution. We have

FZ(z) = P(Z ≤ z) = P(−Z ≥ −z) = P(Z ≥ −z) = 1 − FZ(−z).

With z < 0, we have −z ≥ 0 and using the formula derived earlier,

FZ(z) = 1− FZ(−z) = 1−(1 − 1

2e−λ(−z)

)=

1

2eλz.

Combining the two cases z ≥ 0 and z < 0, we obtain

FZ(z) =

1− 1

2e−λz

if z ≥ 0,

1

2eλz if z < 0,

We now calculate the PDF of Z by differentiating its CDF. We obtain

fZ(z) =

λ

2e−λz if z ≥ 0,

λ

2eλz if z < 0,

or

fZ(z) =λ

2e−λ|z|.

This is known as a two-sided exponential PDF, also known as the LaplacePDF.

Page 199: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

52 General Random Variables Chap. 3

3.7 SUMMARY AND DISCUSSION

Continuous random variables are characterized by PDFs and arise in many ap-plications. PDFs are used to calculate event probabilities. This is similar tothe use of PMFs for the discrete case, except that now we need to integrateinstead of adding. Joint PDFs are similar to joint PMFs and are used to de-termine the probability of events that are defined in terms of multiple randomvariables. Finally, conditional PDFs are similar to conditional PMFs and areused to calculate conditional probabilities, given the value of the conditioningrandom variable.

We have also introduced a few important continuous probability laws andderived their mean and variance. A summary is provided in the table thatfollows.

Summary of Results for Special Random Variables

Continuous Uniform Over [a, b]:

fX(x) =

1

b− aif a ≤ x ≤ b,

0 otherwise,

E[X] =a + b

2, var(X) =

(b− a)2

12.

Exponential with Parameter λ:

fX(x) =

λe−λx if x ≥ 0,0 otherwise,

FX (x) =

1− e−λx if x ≥ 0,0 otherwise,

E[X ] =1

λ, var(X) =

1

λ2.

Normal with Parameters µ and σ2:

fX(x) =1√2πσ

e−(x−µ)2/2σ2,

E[X] = µ, var(X) = σ2.

Page 200: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 53

S O L V E D P R O B L E M S

SECTION 3.1. Continuous Random Variables and PDFs

Problem 1. * Show that the expected value of a continuous random variable Xsatisfies

E[X] =

∫ ∞

0

P(X > x) dx−∫ ∞

0

P(X < −x) dx.

Solution. We have

∫ ∞

0

P(X > x) dx =

∫ ∞

0

(∫ ∞

x

fX(y) dy

)dx

=

∫ ∞

0

(∫ y

0

fX(y) dx

)dy

=

∫ ∞

0

fX(y)

(∫ y

0

dx

)dy

=

∫ ∞

0

yfX(y) dy,

and similarly we show that

∫ ∞

0

P(X < −x)dx = −∫ 0

−∞yfX(y)dy.

Combining the two relations above, we obtain the desired result.

Problem 2. * Laplace random variable. Let X have the PDF

fX(x) =λ

2e−λ|x|

,

where λ is a positive scalar. Verify that fX satisfies the normalization condition. FindE[X] and var(X).

Solution. We have

∫ ∞

−∞fX(x)dx =

∫ ∞

−∞

λ

2e−λ|x|dx = 2 · 1

2

∫ ∞

0

λe−λxdx = 2 · 1

2= 1,

where we have used the normalization property of the exponential PDF,∫∞0

λe−λxdx =1.

Page 201: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

54 General Random Variables Chap. 3

By symmetry of the PDF, we have E[X ] = 0. We also have

E[X2] =

∫ ∞

−∞x2 λ

2e−λ|x|dx =

∫ ∞

0

x2λe−λxdx =2

λ2,

where we have used the fact that the second moment of the exponential PDF is 2/λ2.

Thus var(X) = E[X2]−(E[X]

)2= 2/λ2.

SECTION 3.2. Cumulative Distribution Functions

Problem 3. Find the PDF, the mean, and the variance of the random variable Xwith CDF

FX(x) =

1− a3

x3 if x ≥ a,0 if x < a,

where a is a positive constant.

Solution. We have

fX(x) =dFX

dx(x) =

3a3x−4 if x ≥ a,0 if x < a.

Also

E[X] =

∫ ∞

−∞xfX(x)dx =

∫ ∞

a

x·3a3x−4

dx = 3a3

∫ ∞

a

x−3

dx = 3a3(−1

2x−2

) ∣∣∣∣∣

a

=3a

2.

Finally, we have

E[X2] =

∫ ∞

−∞x2fX(x)dx =

∫ ∞

a

x2·3a3x−4dx = 3a3

∫ ∞

a

x−2dx = 3a3(−x−1

)∣∣∣∣∣

a

= 3a2,

so the variance is

var(X) = E[X2]−

(E[X]

)2= 3a

2 −(

3a

2

)2

=3a2

4.

Problem 4. Consider a triangle with height h. Let X be the distance from the baseof a point randomly chosen within the triangle. What is the CDF and the PDF of X?

Solution. Let A = bh/2 be the area of the given triangle, where b is the length of thebase. From the randomly chosen point, draw a line parallel to the base, and let Ax bethe area of the triangle thus formed. The height of this triangle is h − x and its basehas length b(h − x)/h. Thus Ax = b(h − x)2/(2h). For x ∈ [0, h], we have

FX(x) = 1 −P(X > x) = 1− Ax

A= 1 − b(h− x)2/(2h)

bh/2= 1−

(h− x

h

)2

,

while for x /∈ [0, h], we have FX(x) = 0.

Page 202: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 55

The PDF is obtained by differentiating the CDF. We have

fX(x) =dFX

dx(x) =

2(h−x)

h2 if 0 ≤ x ≤ h,0 otherwise.

Problem 5. * For a nonnegative, integer-valued random variable X, show

E[X] =

∞∑

i=1

P(X ≥ i) =

∞∑

i=0

(1 − FX(i)

).

Solution. We have∞∑

i=1

P(X ≥ i) =

∞∑

i=1

∞∑

k=i

P(X = k)

=

∞∑

k=1

k∑

i=1

P(X = k)

=

∞∑

k=1

kP(X = k).

Problem 6. * The median of a random variable X is the number µ that satisfiesFX(µ) = 1

2 . Find the median of the exponential random variable with parameter λ.

Solution. We are given that FX(µ) = 12 or

1

2=

∫ µ

0

λe−λx dx = −e−λx∣∣∣µ

0= 1 − e−λµ,

or

−λµ = ln1

2,

from which

µ =ln 2

λ.

Problem 7. * Simulating a continuous random variable. Computers havesubroutines that can generate experimental values of a random variable X that isuniformly distributed in the interval [0, 1]. Such a subroutine can be used to generateexperimental values of a continuous random variable with given CDF F (y) as follows:Each time X takes a value x ∈ (0, 1), we generate the unique value y for which F (y) = x.(We can neglect the zero probability event that X takes the value 0 or 1.)

(a) Show that the CDF FY (y) of the random variable Y thus generated is indeedequal to the given F (y).

(b) Describe how the procedure can be used to simulate an exponential randomvariable with parameter λ.

Page 203: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

56 General Random Variables Chap. 3

(c) How can the procedure be generalized to simulate a discrete integer-valued ran-dom variable.

Solution. (a) For the random variable Y thus generated, we have

FY (y) = P(Y ≤ y) ≤ P(X ≤ F (y)

).

But since X is uniformly distributed in [0, 1], we have that P(X ≤ F (y)

)is equal to

F (y).

(b) The exponential PDF has the form F (y) = 1 − e−λy for y ≥ 0. Thus to generatevalues of Y , we should generate values x ∈ (0, 1) of a uniformly distributed randomvariable X, and set y to the value for which 1− e−λy = x, or y = − ln(1− x)/λ.

(c) For a generated value x, let y be the integer such that F (y) < x ≤ F (y + 1).

SECTION 3.3. Normal Random Variables

Problem 8. Let X and Y be normal random variables with means 0 and 1, respec-tively, and variances 1 and 4, respectively.

(a) Find P(X ≤ 1.5) and P(X ≤ −1).

(b) What is the PDF of Z = (Y − 1)/2.

(c) Find P(−1 ≤ Y ≤ 1).

Solution. (a) X is a standard normal, so we have P(X ≤ 1.5) ≤ Φ(1.5) = 0.9332. AlsoP(X ≤ −1) = 1 − Φ(1) = 1− 0.8413 = 0.1587.

(b) By subtracting from Y its mean and dividing by the standard deviation, we obtainthe standard normal.

(c) We have P(−1 ≤ Y ≤ 1) = P(−1 ≤ (Y − 1)/2 ≤ 0) = P(−1 ≤ Z ≤ 0) = P(0 ≤Z ≤ 1) = Φ(1)− Φ(0) = 0.8413− 0.5 = 0.3413.

Problem 9. Let X be a normal random variable with zero mean and standarddeviation σ. Use the normal tables to compute the probabilities of the events X ≥ kσand |X| ≤ kσ for k = 1, 2, 3.

Solution. Let Z be the standard normal random variable. We have X = Z/σ, so

P(X ≥ kσ) = P(Z ≥ k) = 1 − Φ(k).

From the normal tables we have

Φ(1) = 0.8413, Φ(2) = 0.9772, Φ(3) = 0.9986.

Thus P(X ≥ σ) = 0.1587, P(X ≥ 2σ) = 0.0228, P(X ≥ 3σ) = 0.0014.We also have

P(|X| ≤ kσ) = P(|Z| ≤ k) = Φ(k)−P(Z ≤ −k) = Φ(k)−(1 − Φ(k)

)= 2Φ(k)− 1.

Using the normal table values above, we obtain P(|X| ≤ σ) = 0.6826, P(|X| ≤ 2σ) =0.9544, P(|X | ≤ 3σ) = 0.9972.

Page 204: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 57

Problem 10. A city’s temperature is modeled as a normal random variable withmean and standard deviation both equal to 10 degrees Celcius. What is the probabilitythat the temperature at a randomly chosen time will be less or equal to 60 degreesFahreneit?

Solution. If X is the temperature in Celcius, the temperature in Fahreneit is Y =32 + 9X/5. Therefore, 60 degrees Fahreneit corresponds to 15 degrees Celcius. So if Zis the standard normal, we have using E[X ] = σX = 10,

P(Y ≥ 60) = P(X ≥ 15) = P

(Z ≥ 15− E[X]

σX

)= P(Z ≥ 0.5) = 1 − Φ(0.5).

From the normal tables we have Φ(0.5) = 0.6915, so P(Y ≥ 60) = 0.3085.

Problem 11. * Show that the normal PDF satisfies the normalization property.

Solution. We note that

(∫ ∞

−∞

1√2π

e−x2

2 dx

)2

=1

∫ ∞

−∞e−x2

2 dx

∫ ∞

−∞e− y2

2 dy

=1

∫ ∞

−∞

∫ ∞

−∞e−

x2+y2

2 dx dy

=1

∫ 2π

0

∫ ∞

0

e−r2

2 rdrdθ

=

∫ ∞

0

e−r2

2 rdr

= −e−u

∣∣∣∣∞

0

= 1.

Thus we have ∫ ∞

−∞

1√2π

e−x2

2 dx = 1,

because the integral is positive. It follows that

∫ ∞

−∞fX(x) dx =

∫ ∞

−∞

1√2πσ

e− (x−µ)2

2σ2 dx =

∫ ∞

−∞

1√2π

e−u2

2 du = 1.

SECTION 3.4. Conditioning on an Event

Problem 12. Let X be a random variable with PDF

fX(x) = x

4 if 1 < x ≤ 3,0 otherwise,

and let A be the event X ≥ 2.

Page 205: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

58 General Random Variables Chap. 3

(a) Find E[X], P(A), and E[X |A].

(b) Let Y = X2. Find E[Y ] and var(Y ).

Solution. (a) We have

E[X ] =

∫ 3

1

x2

4dx =

13

6,

P(A) =

∫ 3

2

x

4dx =

5

8.

To obtain E[X |A], we compute fX |A(x |A). We have

fX |A(x |A) =

fX (x)

P(A)if x ∈ A,

0 otherwise,=

2x5 if 2 ≤ x ≤ 3,

0 otherwise,

from which

E[X |A] =

∫ 3

2

x · 2x

5dx =

38

15.

(b) We have

E[Y ] = E[X2] =

∫ 3

1

x3

4dx = 5.

We also have

E[Y 2] = E[X4] =

∫ 3

1

x5

4dx =

91

3.

Thus

var(Y ) = E[Y 2] −(E[Y ]

)2=

91

3− 52 =

16

3.

Problem 13. The random variable X has the PDF

fX(x) =

cx−2 if 1 ≤ x ≤ 2,0 otherwise.

(a) Determine the numerical value of c.

(b) Let A be the event X > 1.5. Calculate P(A) and sketch the conditional PDFfor X given that A has occurred.

(c) Let Y = X2. Calculate the conditional expectation and the conditional variancefor Y given A.

Solution. (a)

c =1∫ 2

1x−2dx

= 2.

(b)

P(A) =

∫ 2

1.5

2x−2

dx =1

3.

Page 206: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 59

fX |A(x |A) =

6x−2 if 1.5 < x ≤ 2,0 otherwise.

(c) We have

E[Y |A] = E[X2 |A] =

∫ 2

1.5

6x−2x2dx = 3,

E[Y 2 |A] = E[X4 |A] =

∫ 2

1.5

6x−2x4dx =37

4,

and

var(Y |A) =37

4− 32 =

1

4.

Problem 14. Calamity Jane goes to the bank to make a deposit, and is equallylikely to find 0 or 1 customer ahead of her. The times of service of these customersare independent and exponentially distributed with parameter λ. What is the CDF ofJane’s waiting time?

Solution. Let X be the waiting time and Y be the number of customers found. Forx < 0, we have FX(x) = 0. For x ≥ 0,

FX(x) = P(X ≤ x) =1

2

(P(X ≤ x |Y = 0) + P(X ≤ x |Y = 1)

).

We have

P(X ≤ x |Y = 0) = 1,

P(X ≤ x |Y = 1) = 1 − e−λx

.

Thus

FX(x) =1

2(2− e

−λx), x ≥ 0.

Problem 15. An absent-minded professor schedules two student appointmentsfor the same time. The appointment durations are independent and exponentiallydistributed with mean thirty minutes. The first student arrives on time, but the secondstudent arrives five minutes late. What is the expected value of the time between thearrival of the first student and the departure of the second student?

Solution. The expected value in question is

E[Time] = (5 + E[stay of 2nd student]) ·P(1st stays less or equal to 5 minutes)

+(E[stay of 1st | stay of 1st ≥ 5] + E[stay of 2nd]

)

·P(1st stays more than 5 minutes).

We have E[stay of 2nd student] = 30, and, using the memoryless property of theexponential distribution,

E[stay of 1st | stay of 1st ≥ 5] = 5 + E[stay of 1st] = 35.

Page 207: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

60 General Random Variables Chap. 3

Also

P(1st student stays less or equal to 5 minutes) = 1− e−5/30,

P(1st student stays more than 5 minutes) = e−5/30.

By substitution we obtain

E[Time] = (5 + 30) · (1− e−5/30) + (35 + 30) · e−5/30 = 35 + 30 · e−5/30 = 60.394.

Problem 16. Alvin throws darts at a circular target of radius R and is equallylikely to hit any point in the target. Let X be the distance of Alvin’s hit from thecenter.

(a) Find the PDF, the mean, and the variance of X.

(b) The target has an inner circle of radius T . If X ≤ T , Alvin gets a score ofS = 1/X . Otherwise his score is S = 0. Find the CDF of S. Is S a continuousrandom variable?

Solution. (a) For x ∈ [0, R], we have

P(X ≤ x) =πx2

πR2=

(x

R

)2

.

By differentiating, we obtain the PDF

fX(x) =

2xR2 if 0 ≤ x ≤ R,0 otherwise.

We have

E[X ] =

∫ R

0

2x2

R2dx =

2R

3.

Also

E[X2] =

∫ R

0

2x3

R2dx =

R2

2,

so

var(X) = E[X2] −(E[X]

)2=

R2

2− 4R2

9=

R2

18.

(b) If s < 0, we have P(S ≤ s) = 0, and if 0 ≤ s < 1/T , we have

P(S ≤ s) = P(Alvin’s hit is outside the inner circle) = 1 −P(X ≤ T ) = 1 − T 2

R2.

Finally if 1/T ≤ s, we have

P(S ≤ s) = P(X ≤ T )P(S ≤ s |X ≤ T ) + P(X > T )P(S ≤ s |X > T ).

We have

P(X ≤ T ) =T 2

R2, P(X > T ) = 1 − T 2

R2,

Page 208: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 61

and since S = 0 when X > T , we have

P(S ≤ s |X > T ) = 1.

Finally, we have

P(S ≤ s |X ≤ T ) = P(1/X ≤ s |X ≤ T ) =P(1/s ≤ X ≤ T )

P(X ≤ T )=

πT 2−π(1/s)2

πR2

πT2

πR2

= 1− 1

s2T 2.

Combining the above relations, we obtain

P(S ≤ s) =T 2

R2

(1 − 1

s2T 2

)+ 1 − T 2

R2= 1 − 1

s2R2.

Collecting the results of the preceding calculations, the CDF of S is

FS(s) =

0 if s < 0,

1 − T2

R2 if 0 ≤ s < 1/T ,

1 − 1s2R2 if 1/T ≤ s.

Because FS has a discontinuity at S = 0, the random variable S is not continuous.

Problem 17. * Consider the following two-sided exponential PDF

fX(x) =

pλe−λx if x ≥ 0,(1− p)λeλx if x < 0,

where λ and p are scalars with λ > 0 and p ∈ [0, 1]. Find the mean and the varianceof X in two ways:

(a) By straightforward calculation of the associated expected values.

(b) By using a divide-and-conquer strategy and the mean and variance of the (one-sided) exponential random variable.

Solution. (a)

E[X] =

∫ ∞

−∞xfX(x)dx

=

∫ 0

−∞x(1− p)λe

λxdx +

∫ ∞

0

xpλe−λx

dx

= −1− p

λ+

p

λ

=2p− 1

λ,

E[X2] =

∫ ∞

−∞x2fX(x)dx

=

∫ 0

−∞x

2(1− p)λe

λxdx +

∫ ∞

0

x2pλe

−λxdx

=2(1− p)

λ2+

2p

λ2=

2

λ2,

Page 209: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

62 General Random Variables Chap. 3

and

var(X) =2

λ2−

(2p− 1

λ

)2

.

(b) Let Y be an exponential random variable with parameter λ and let Z be a 0-1random variable with a probability p of being 1. Noting that

fX(x) = pfY (x) + (1− p)f−Y (x),

we can express X as

X =

Y if Z = 1,−Y if Z = 0.

It follows that

E[X ] = P(Z = 1)E[X |Z = 1] + P(Z = 0)E[X |Z = 0]

= pE[Y ] + (1− p)E[−Y ]

=p

λ− 1− p

λ

=2p− 1

λ,

E[X2] = P(Z = 1)E[X2 |Z = 1] + P(Z = 0)E[X2 |Z = 0]

= pE[Y2] + (1− p)E[(−Y )

2]

=2p

λ2+

2(1 − p)

λ2

=2

λ2.

and

var(X) =2

λ2−

(2p− 1

λ

)2

.

Problem 18. * Mixed random variables. Probability models sometimes involverandom variables which can be viewed as a mixture of a discrete random variable Yand a continuous random variable Z. By this we mean that the experimental value ofX is obtained according to the probability law of Y with a given probability p, andaccording to the probability law of Z with the complementary probability 1−p. Then,X is called a mixed random variable and its CDF is given, using the total probabilitytheorem, by

FX(x) = P(X ≤ x)

= pP(Y ≤ x) + (1− p)P(Z ≤ x)

= p · FY (x) + (1− p) · FZ(x)

.

Its expected value is defined in a way that conforms to the total expectation theorem:

E[X] = pE[Y ] + (1− p)E[Z].

The taxi stand and the bus stop near Al’s home are in the same location. Al goesthere at a given time and if a taxi is waiting (this happens with probability 2/3) he

Page 210: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 63

boards it. Otherwise he waits for a taxi or a bus to come, whichever comes first. Thenext taxi will arrive in a time that is uniformly distributed between 0 and 10 minutes,while the next bus will arrive in exactly 5 minutes. The probability of boarding thenext bus, given that Al has to wait, is

P(a taxi will take more than 5 minutes to arrive) =1

2.

Find the CDF and the expected value of Al’s waiting time.

Solution. Let A be the event that Al will find a taxi waiting or will be picked up by thebus after 5 minutes. Al’s waiting time, call it X , is a mixed random variable. Withprobability

P(A) =2

3+

1

3· 1

2=

5

6,

it is equal to its discrete component Y (corresponding to either finding a taxi waiting,or boarding the bus), which has PMF

pY (y) =

23P(A) if y = 0,

16P(A)

if y = 5,=

1215

if y = 0,315 if y = 5.

[This equation follows from the following calculation:

pY (0) = P(Y = 0 |A) =P(Y = 0, A)

P(A)=

P(Y = 0)

P(A)=

2

3P(A),

and the calculation for pY (1) is similar.] With the complementary probability 1−P(A),the waiting time is equal to its continuous component Z (corresponding to boarding ataxi after having to wait for some time less than 5 minutes), which has PDF

fZ(z) =

1/5 if 0 ≤ z ≤ 5,0 otherwise.

The CDF is given by fX(x) = P(A)fY (y) +(1−P(A)

)fZ(z) or

FX(x) =

0 if x < 0,56

1215

+ 16

z5

if 0 ≤ x < 5,1 if 5 ≤ x.

The expected value of the waiting time is

E[X] = P(A)E[Y ] +(1 −P(A)

)E[Z] =

5

6· 3

15· 5 +

1

6· 5

2=

15

12.

SECTION 3.5. Multiple Continuous Random Variables

Problem 19. A history professor is so disorganized, that on any given day, he isequally likely to be lecturing about any event in the past 1000 years, regardless of what

Page 211: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

64 General Random Variables Chap. 3

he lectured on at any point in the past. Find the CDF of the time separating thesubject matter of any two lectures.

Solution. The date of the events upon which the professor lectures on any given day, isuniformly distributed from 0 to 1000, independently of other lectures. Let X1 be thedate of the material covered in lecture 1, and X2 be the date of the material of lecture2. Let A be the event X1 < X2 and let T = |X1 −X2|. Then the CDF of T is

FT (t) = P(|X1 −X2| ≤ t) =1

2P(X1 −X2 ≤ t |Ac) +

1

2P(X2 −X1 ≤ t |A).

We have

P(X1 −X2 ≤ t |Ac) = P(X2 −X1 ≤ t |A) =

0 if t < 0,

1− (1000−t)2

(1000)2if 0 ≤ t ≤ 1000,

1 if t > 1000,

so FT (t) is also equal to the above expression.

Problem 20. The random variables X and Y describe the cartesian coordinates ofa random point within a unit circle centered at the origin. Let W = maxX,Y . Findthe CDF of W . You need not evaluate integrals.

Solution. To find the CDF of W , we need to find

P(W ≤ w) = P(maxX, Y ≤ w) = P(X ≤ w,Y ≤ w).

To calculate this we need to integrate the joint density of X,Y over the region whereboth are smaller than w. This region is the infinite quarter of the plane, with upperright hand corner at (w, w). Clearly, there are several cases to consider, dependingupon the value of w, since the joint PDF of X and Y , is only nonnegative within theunit circle centered at the origin. Thus, we have

FW (w) =

0 if w ≤ −√

22 ,

∫ w

−√

1−w2(w +√

1− x2)dx if −√

22 < w ≤ 0,

14 +

w2+2w√

1−w2

π + 2π

∫ −√1−w2

−1

√1 − x2 dx if 0 < w ≤

√2

2 ,

1 − 4π

∫ 1

w

√1 − x2 dx if

√2

2 < w ≤ 1,1 if w > 1.

Problem 21. Consider the random variables X and Y with joint PDF of the form

fX,Y (x, y) = γx2y, for x ≥ 0, y ≥ 0, x + 3y ≤ 10.

(a) Find the value of the constant γ.

(b) Find E[maxX,Y

].

Solution. (a) The normalization property requires that

γ =

( ∫ 10

0

∫ 10−x3

0

x2y dy dx

)−1

=54

10, 000

Page 212: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 65

(b) The expectation of the maximum of X and Y will be the sum of two integrals,since we have

maxx, y =

x if x ≥ y,y otherwise.

Let A be the region where x ≥ y and where the joint PDF is nonzero, and let B be theregion where x < y. Then we have

E[maxX,Y

]=

∫ ∫

(x,y)∈A

xfX,Y (x, y)d(Area) +

∫ ∫

(x,y)∈B

yfX,Y (x, y)d(Area),

or

E[maxX, Y

]=

A

xfX,Y (x, y)d(Area) +

B

yfX,Y (x, y)d(Area)

=

∫ 10/4

0

∫ 10−3y

y

xγx2y dx dy +

∫ 10/4

0

∫ (10−x)/3

x

yγx2y dy dx.

Problem 22. A point is chosen at random from a semicircle of radius R. Thesemicircle is centered at the origin, and is in the upper half plane.

(a) Find the joint PDF of its coordinates X and Y .

(b) Find the marginal PDF of Y and use it to find E[Y ].

(c) Now check your answer in (b) by computing E[Y ] without using the marginalPDF of Y .

Solution. (a) The point is randomly chosen from the half circle. We take this tomean that it is uniformly distributed there. Thus the joint PDF of X,Y must befX,Y (x, y) = 2/πR2.

(b) To find the marginal PDF of Y , we integrate the joint PDF over the range of X:

fY (y) =

∫ A

−A

2

πR2dx =

4A

πR2 if 0 ≤ y ≤ R,0 otherwise.

where A =√

R2 − y2. We have

E[Y ] =4

πR2

∫ R

0

y√

R2 − y2 dy =4R

3π,

where the integration is performed using the substitution z = R2 − y2.

(c) There is no need to find the marginal PDF fY in order to find the expectation. LetD denote the semicircle. We have

E[Y ] =

D

yfX,Y (x, y)dxdy =

∫ π

0

∫ R

0

2

πR2r sin θ rdrdθ =

4R

3π.

Problem 23. Let X and Y be independent continuous random variables with PDFsfX and fY , respectively.

Page 213: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

66 General Random Variables Chap. 3

(a) Show that fX+Y |X(z | x) = fY (z − x).

(b) Assume now that X and Y are independent exponentially distributed randomvariables with mean equal to 1. Find the conditional PDF of X, given thatX + Y = z.

Solution. (a) We have P(X + Y ≤ z |X = x) = P(x + Y ≤ z) = P(Y ≤ z − x). Bydifferentiating both sides with respect to z, the result follows.

(b) Let Z = X + Y . We have, for 0 ≤ x ≤ z,

fX |Z(x, z) =fZ |X(z |x)fX(x)

fZ(z)=

fY (z − x)fX(x)

fZ(z)=

e−(z−x)e−x

fZ(z)=

e−z

fZ(z).

Since this is the same for all x, it follows that the conditional distribution of X isuniform on the interval [0, z], with PDF fX |Z(x | z) = 1/z.

Problem 24. * Let X , Y , and Z be three random variables with joint PDFfX,Y,Z(x, y, z). Show the multiplication rule:

fX,Y,Z(x, y, z) = fX|Y,Z(x | y, z)fY |Z(y | z)fZ(z).

Solution. We have using the definition of conditional density

fX|Y,Z(x | y, z) =fX,Y,Z(x, y, z)

fY,Z(y, z),

andfY,Z(y, z) = fY |Z(y | z)fZ(z).

Combining these two relations, we obtain the multiplication rule.

Problem 25. * Consider two continuous random variables with joint PDF fX,Y .Show that the two different expressions

∫xfX(x) dx, and

∫ ∫xfX,Y (x, y)dx dy

for E[X ] are equal.

Solution. We have

∫ ∫xfX,Y (x, y) dx dy =

∫ ∫xfX,Y (x, y) dy dx

=

∫x

∫fX,Y (x, y)dy dx

=

∫xfX(x)dx,

where the last step makes use of the formula fX(x) =∫

fX,Y (x, y)dy.

Problem 26. * Estimating an expected value by simulation. Let fX(x) bea PDF such that for some nonnegative scalars a, b, and M we have fX(x) = 0 for all

Page 214: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 67

x /∈ [a, b] and xfX(x) ≤ M for all x. Let Yi, i = 1, . . . ,N , be independent randomvariables with values generated as follows: a point (v, w) is chosen at random withinthe rectangle whose corners are (a, 0), (b, 0), (a, M ), and (b, M ), and if w ≤ vfX(v),the value of Yi is set to 1, and otherwise it is set to 0. Consider the random variable

Z =Y1 + · · · + YN

N.

Show that

E[Z] =E[X]

M(b− a)

and

var(Z) ≤ 1

4N.

In particular, we have var(Z) → 0 as N →∞.

Solution. We have

P(Yi = 1) = P(w ≤ vfX(v)

)=

∫ b

axfX(x)dx

M (b− a)=

E[X]

M (b− a).

According to the example in Section 2.7, the random variable Z has mean P(Yi = 1)and variance P(Yi = 1)

(1 − P(Yi = 1)

)/N. Since 0 ≤ (1 − 2p)2 = 1 − 4p(1 − p), we

have p(1− p) ≤ 1/4 for any p, so it follows that var(Z) ≤ 1/(4N ).

Problem 27. * Consider the following variant of the Buffon needle problem (Example3.15). A needle of length l is dropped on a plane surface that is partitioned in rectangleswith sides whose lengths are a and b. Suppose that the needle’s length l satisfies l < aand l < b. What is the expected number of recatangle sides crossed by the needle?What is the probability that the needle will cross at least one side of some rectangle.

Solution. Let A be the event that the needle will cross a horizontal line, and let B bethe probability that it will cross a vertical line. From the analysis of Example 3.15, wehave that

P(A) =2l

πa, P(B) =

2l

πb.

Since at most one horizontal (or vertical) line can be crossed, the expected number ofhorizontal lines crossed is P(A) [or P(B), respectively]. Thus the expected number ofcrossed lines is

P(A) + P(B) =2l

πa+

2l

πb=

2l(a + b)

πab.

The probability that at least one line will be crossed is

P(A ∪ B) = P(A) + P(B)−P(A ∩ B).

Let X (or Y ) be the distance from the needle’s center to the nearest horizontal (orvertical) line. Let Θ be the angle formed by the needle’s axis and the horizontal linesas in Example 3.15. We have

P(A ∩ B) = P(

X ≤ l sinΘ

2, Y ≤ l cos Θ

2

),

Page 215: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

68 General Random Variables Chap. 3

and the triple (X,Y, Θ) is uniformly distributed over the set [0, a/2]× [0, b/2]× [0, π/2].Hence, within in this set, we have

fX,Y,Θ(x, y, θ) =8

πab.

The probability P(A ∩ B) is

P(X ≤ (l/2) sin Θ, Y ≤ (l/2) cosΘ

)=

∫ ∫

x≤(l/2) sin θy≤(l/2) cos θ

fX,Y,Θ(x, y, θ)dx dy dθ

=8

πab

∫ π/2

0

∫ (l/2) cos θ

0

∫ (l/2) sin θ

0

dx dy dθ

=2l2

πab

∫ π/2

0

cos θ sin θ dθ

=l2

πab.

Thus we have

P(A ∪ B) = P(A) + P(B) −P(A ∩ B) =2l

πa+

2l

πb− l2

πab=

l

πab

(2(a + b) − l

).

Problem 28. * Consider two continuous random variables with joint PDF fX,Y .Suppose that for any subsets A and B of the real line, the events X ∈ A and Y ∈ Bare independent. Show that the random variables X and Y are independent.

Solution. For any two real numbers x and y, we use the independence of the eventsX ≤ x and Y ≤ y to obtain,

FX,Y (x, y) = P(X ≤ x, Y ≤ y) = P(X ≤ x)P(Y ≤ y) = FX(x)FY (y).

We take derivatives of both sides, to obtain

fX,Y (x, y) =∂FX,Y

∂x∂y=

∂FX

∂x(x)

∂FY

∂y(y) = fX(x)fY (y),

which establishes that the random variables X and Y are independent.

Problem 29. * Random sums of random variables. You visit a random numberN of stores and in the ith store, you spend a random amount of money Xi. What isthe mean and variance of the total amount of money

T = X1 + X2 + · · ·+ XN

that you spend? We assume that N is a discrete random variable with a given PMFand that the Xi are random variables with the same mean E[X] and variance var(X).Furthermore, we assume that N and all the Xi are independent.

Page 216: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 69

Solution. Let Ai be the event that you visit i stores, i.e.,

Ai = N = i.

Then, we have for all i,E[T |Ai] = iE[X],

since conditional on Ai, you will visit exactly i stores, and you will spend an expectedamount of money E[X] in each.

We now apply the total expectation theorem. We have

E[T ] =

∞∑

i=1

P(Ai)E[T |Ai]

=

∞∑

i=1

P(N = i)iE[X]

= E[X]

∞∑

i=1

iP(N = i)

= E[X] ·E[N ].

Similarly, using also the independence of the Xi, which implies that E[XiXj ] =(E[X ]

)2

if i 6= j, the second moment of T is calculated as

E[T 2] =

∞∑

i=1

P(Ai)E[T 2 |Ai]

=

∞∑

i=1

P(Ai)E[(X1 + · · · + XN )

2 |Ai

]

=

∞∑

i=1

P(N = i)(iE[X

2] + i(i− 1)

(E[X ]

)2)

= E[X2]

∞∑

i=1

iP(N = i) +(E[X]

)2∞∑

i=1

i(i− 1)P(N = i)

= E[X2]E[N ] +

(E[X ]

)2(E[N

2]− E[N ]

)

= var(X)E[N ] +(E[X ]

)2E[N2].

The variance is then obtained by

var(T ) = E[T 2]−(E[T ]

)2

= var(X)E[N ] +(E[X]

)2E[N2]−

(E[X]

)2(E[N ]

)2

= var(X)E[N ] +(E[X]

)2(E[N

2] −

(E[N ]

)2),

so finally

var(T ) = var(X)E[N ] +(E[X]

)2var(N).

Page 217: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

70 General Random Variables Chap. 3

Note: The formulas for E[T ] and var(T ) will also be obtained with alternative methodsin Chapter 4.

SECTION 3.6. Derived Distributions

Problem 30. The metro train arrives at the station near your home every quarter hourstarting at 6:00 AM. You walk into your station every morning between 7:10 and 7:30 AM,with the time in this interval being a random variable with given PDF (cf. Example 3.12).Let X be the difference in minutes between 7:10 and the time of your arrival. Calculatethe CDF of Y in terms of the CDF of X and differentiate to obtain the PDF of Y .

Solution. We have

FY (y) =

0 if y ≤ 0,P(5− y ≤ X ≤ 5) + P(20− y ≤ X ≤ 20) if 0 ≤ y ≤ 5,P(20 − y ≤ X ≤ 20) if 5 < y ≤ 15,1 if y > 15.

Using the CDF of X, we have

P(5− y ≤ X ≤ 5) = FX(5)− FX(5− y),

P(20 − y ≤ X ≤ 20) = FX(20) − FX(20− y).

Thus, we have

FY (y) =

0 if y ≤ 0,FX(5)− FX(5− y) + FX(20) − FX(20 − y) if 0 ≤ y ≤ 5,FX(20)− FX(20− y) if 5 < y ≤ 15,1 if y > 15.

Differentiating, we obtain

fY (y) =

fX(5− y) + fX(20 − y) if 0 ≤ y ≤ 5,fX(20− y) if 5 < y ≤ 15,0 otherwise,

consistently with the result of Example 3.12.

Problem 31. Let X be a uniformly distributed random variable between 0 and 1.Show that the PDF of Y = cos πX is

fY (y) =1

π√

1 − y2, for −1 < y < 1.

Solution. We have

FY (y) = P(Y ≤ y) = P(

1

πcos−1 y ≤ X ≤ 1

)= 1 − 1

πcos−1 y

Page 218: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 71

and therefore by differentiation

fY (y) =1

π√

1 − y2, for −1 < y < 1.

Problem 32. If the random variable Θ is uniformly distributed between −π and π, findthe density function for random variable X = cosΘ.

Solution. We first find the CDF, and then take the derivative to find the PDF.

P(X ≤ x) = P(cos Θ ≤ x) =1

π(π − cos−1 x)

and therefore

fX(x) =1

π· 1√

1− x2.

Problem 33. If X is normally distributed, with mean µ and variance σ2 find the PDFof the random variable Y = eX .

Solution. We first find the CDF, and then take the derivative to find the PDF. We have

P(Y ≤ y) = P(eX ≤ y) =

P(X ≤ ln y) if y > 0,0 otherwise.

Therefore

fY (y) =

d

dxFX(ln y) if y > 0,0 otherwise,

=

1yfX(ln y) if y > 0,

0 otherwise.

Problem 34. Suppose X is uniformly distributed between 0 and 1. Find the PDF ofY = eX .

Solution. We have

FY (y) = P(Y ≤ y) = P(eX ≤ y) = P(X ≤ ln y) = ln y

and thus

fY (y) =1

y, for 0 < y ≤ e.

Problem 35. If X is a random variable that is uniformly distributed between -1 and 1,find the PDF of Y =

√|X| and the PDF of Y = − ln |X |.

Solution. Let Y =√|X |. We have

FY (y) = P(Y ≤ y) = P(√|X | ≤ y) = P(−y2 ≤ X ≤ y2) = y2

and therefore by differentiation

fY (y) = 2y, for 0 ≤ y ≤ 1.

Page 219: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

72 General Random Variables Chap. 3

Let Y = − ln |X|. We have

FY (y) = P(Y ≤ y) = P(ln |X | ≥ −y) = P(X ≥ e−y) + P(X ≤ −e−y) = 1 − e−y,

and therefore by differentiation

fY (y) = e−y, for 0 ≤ y <∞.

Problem 36. Suppose that X is a standard normal random variable. Find the PDF of

Y = |X | 13 and Y = |X| 14 .

Solution. Let Y = |X| 13 . We have

FY (y) = P(Y ≤ y) = P(|X |13 ≤ y) = P(−y3 ≤ X ≤ y3) = FX(y3)− FX(−y3)

and therefore

fY (y) = 3y2fX(y3) + 3y2fX(−y3) = 6y2fX(y3), for y > 0.

Let Y = |X| 14 . We have

FY (y) = P(Y ≤ y) = P(|X |14 ≤ y) = P(−y4 ≤ X ≤ y4) = FX(y4)− FX(−y4)

and therefore

fY (y) = 4y3fX(y4) + 4y3fX(−y4) = 8y3fX(y4), for y > 0.

Problem 37. Let X and Y be independent random variables, uniformly distributedon the interval [0, 1]. Find the PDF of X − Y .

Solution. We have P (|X − Y | ≤ a) = 1− (1−a)2. (To see this, draw the event of interestas a subset of the unit square and calculate its area.) Taking derivatives, the desired PDFis fZ(z) = 2(1− z), for 0 ≤ z ≤ 1, and zero otherwise.

Problem 38. Let X and Y be the cartesian coordinates of a random point on the trianglewith vertices at (0, 1), (0,−1), and (1, 0). Find the CDF and the PDF of Z = |X − Y |.Solution. To find the CDF, we integrate the joint density of X, and Y over the regionwhere |X − Y | ≤ z for a given z. In the case where z ≤ 0 or z ≥ 1, the CDF is 0 and 1,respectively. In the case where 0 < z < 1, we have

FZ(z) = P(|X − Y | ≤ z |X ≥ Y )P(X ≥ Y ) + P(Y −X ≤ z |X < Y )P(X < Y )

=

(z

2+

z2

4

)+

(1

4− (1− z)2

4

)

= z.

We have

FZ(z) =

0 if z ≤ 0,z if 0 < z < 1,1 if z ≥ 1.

Page 220: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 73

By taking the derivative with respect to Z, we obtain

fZ(z) =

1 if 0 ≤ z ≤ 1,0 otherwise.

Problem 39. Consider the Romeo and Juliet Example 3.29, but assume that the timesX and Y are independent and exponentially distributed with different parameters λX andλY . Find the PDF of Z = X − Y .

Solution. We will first calculate the CDF FZ(z) by considering separately the cases z ≥ 0and z < 0. For z ≥ 0, we have (see the left side of Fig. 3.26)

FZ(z) = P(X − Y ≤ z)

= 1 −P(X − Y > z)

= 1 −∫ ∞

0

(∫ ∞

z+y

fX,Y (x, y)dx

)dy

= 1 −∫ ∞

0

λY e−λY y

(∫ ∞

z+y

λXe−λXx

dx

)dy

= 1 −∫ ∞

0

λY e−λY ye−λX (z+y) dy

= 1 − e−λXz

∫ ∞

0

λY e−(λX+λY )y dy

= 1 − λY

λX + λYe−λXz

.

For the case z < 0, we have using the preceding calculation

FZ(z) = 1 − FZ(−z) = 1 −(1 − λX

λX + λYe−λY (−z)

)=

λX

λX + λYeλY z.

Combining the two cases z ≥ 0 and z < 0, we obtain

FZ(z) =

1 − λY

λX+λYe−λXz if z ≥ 0,

λXλX+λY

eλY z if z < 0,

The PDF of Z is obtained by differentiating its CDF. We have

fZ(z) =

λXλY

λX+λYe−λXz if z ≥ 0,

λXλYλX+λY

eλY z if z < 0.

Problem 40. * Two points are chosen randomly and independently from the interval[0, 1]. Show that the expected value of the distance from each point to the nearest endpointof the interval is 1/3, and that the expected value of the distance between the two pointsis also 1/3.

Page 221: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

74 General Random Variables Chap. 3

Solution. Let X and Y be the two points, and let Z = maxX,Y . For any t ∈ [0, 1], wehave

P(Z ≤ t) = P(X ≤ t)P(Y ≤ t) = t2,

and by differentiating, the corresponding PDF is

fZ(z) =

0 if z ≤ 0,2z if 0 ≤ z ≤ 1,0 if z ≥ 1.

Thus, we have

E[Z] =

∫ ∞

−∞zfZ(z)dz =

∫ 1

0

2z2dz =2

3.

The distance of the largest of the two points to the nearest endpoint is 1 − Z, and itsexpected value is 1 − E[Z] = 1/3. A symmetric argument shows that the distance of thesmallest of the two points to the nearest endpoint is also 1/3. Since the expected distancesto the nearest endpoints are 1/3, the expected distance between the two points must alsobe 1/3.

Problem 41. * Competing exponentials. Two runners run a long distance coursein times X and Y , which are independent and exponentially distributed with parametersλX and λY , respectively. The winner’s time is

Z = minX,Y .

Show that the CDF of Z is exponential with parameter λX + λY .

Solution. For all z ≥ 0, we have, using the independence of X and Y , and the form of theexponential CDF,

FZ(z) = P(minX,Y ≤ Z

)

= 1−P(minX, Y > Z

)

= 1−P(X > Z, Y > Z)

= 1−P(X > Z)P(Y > Z)

= 1− e−λXze−λY z

= 1− e−(λX+λY )z.

This is recognized as the exponential CDF with parameter λX +λY . Thus, the minimum oftwo exponentials with parameters λX and λY is an exponential with parameter λX +λY .

Problem 42. * Cauchy random variable.

(a) Let X be a uniformly distributed random variable between 0 and 1. Show that the PDFof Y = tan πX is

fY (y) =1

π

1

1 + y2, −∞ < y < ∞.

(Y is called a Cauchy random variable.)

(b) Let Y be a Cauchy random variable. Find the PDF of the random variable

X = tan−1 Y.

Page 222: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 3.7 Summary and Discussion 75

Solution. (a) For y < 0, we have

FY (y) = P(Y ≤ y) = P(

1

2≤ X ≤ 1

πtan−1 y + 1

)=

1

πtan−1 y +

1

2.

Also for y > 0, we have

FY (y) = P(Y ≤ y) = P(0 ≤ X ≤ 1

πtan

−1y)

+ P(

1

2≤ X ≤ 1

)=

1

πtan

−1y +

1

2.

Therefore, by differentiation,

fY (y) =1

π

1

1 + y2, for −∞ < y <∞.

(b) We first compute the CDF and then differentiate to obtain the PDF of X. We have

P(X ≤ x) = P(tan−1 Y ≤ x) = P(Y ≤ tan x) =1

π

∫ tan x

−∞

1

1 + y2dy =

1

π·(

x +π

2

).

Taking the derivative, we find that X is uniformly distributed on an interval of length π, andby the definition of tan−1 the interval must be [− π

2 , π2 ].

Page 223: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

4

Further Topics

on Random Variables and Expectations

Contents

4.1. Transforms . . . . . . . . . . . . . . . . . . . . . . . p. 24.2. Sums of Independent Random Variables - Convolutions . . . p. 134.3. Conditional Expectation as a Random Variable . . . . . . . p. 174.4. Sum of a Random Number of Independent Random Variables p. 254.5. Covariance and Correlation . . . . . . . . . . . . . . . p. 294.6. Least Squares Estimation . . . . . . . . . . . . . . . . p. 324.7. The Bivariate Normal Distribution . . . . . . . . . . . . p. 39

1

Page 224: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

2 Further Topics on Random Variables and Expectations Chap. 4

In this chapter, we develop a number of more advanced topics. We introducemethods that are useful in:

(a) dealing with the sum of independent random variables, including the casewhere the number of random variables is itself random;

(b) addressing problems of estimation or prediction of an unknown randomvariable on the basis of observed values of other random variables.

With these goals in mind, we introduce a number of tools, including transformsand convolutions, and refine our understanding of the concept of conditionalexpectation.

4.1 TRANSFORMS

In this section, we introduce the transform associated with a random variable.The transform provides us with an alternative representation of its probabilitylaw (PMF or PDF). It is not particularly intuitive, but it is often convenient forcertain types of mathematical manipulations.

The transform of the distribution of a random variable X (also referredto as the moment generating function of X) is a function MX(s) of a freeparameter s, defined by

MX (s) = E[esX ].

The simpler notation M(s) can also be used whenever the underlying randomvariable X is clear from the context. In more detail, when X is a discrete randomvariable, the corresponding transform is given by

M(s) =∑

x

esxpX(x),

while in the continuous case, we have†

M(s) =

∫ ∞

−∞esxfX(x) dx.

Example 4.1. Let

pX(x) =

1/2, if x = 2,1/6, if x = 3,1/3, if x = 5.

† The reader who is familiar with Laplace transforms may recognize that the trans-

form associated with a continuous random variable is essentially the same as the Laplace

transform of its PDF, the only difference being that Laplace transforms usually involve

e−sx rather than esx. For the discrete case, a variable z is sometimes used in place

of es and the resulting transform M (z) =∑

xzxpX(x) is known as the z-transform.

However, we will not be using z-transforms in this book.

Page 225: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.1 Transforms 3

Then, the corresponding transform is

M (s) =1

2e2s +

1

6e3s +

1

3e5s

(see Fig. 4.1).

2 3 5

12

16

13

x

pX(x)

M(s)

s0

1 (1/2) e2s

(1/6) e3s

(1/3) e5s

0

Figure 4.1: The PMF and the corresponding transform for Example 4.1. Thetransform M(s) consists of the weighted sum of the three exponentials shown.Note that at s = 0, the transform takes the value 1. This is generically true since

M(0) =∑

x

e0·xpX (x) =∑

x

pX(x) = 1.

Example 4.2. The Transform of a Poisson Random Variable. Consider aPoisson random variable X with parameter λ:

pX(x) =λxe−λ

x!, x = 0, 1, 2, . . .

The corresponding transform is given by

M (s) =

∞∑

x=0

esx λxe−λ

x!.

Page 226: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

4 Further Topics on Random Variables and Expectations Chap. 4

We let a = esλ and obtain

M (s) = e−λ

∞∑

x=0

ax

x!= e−λea = ea−λ = eλ(es−1).

Example 4.3. The Transform of an Exponential Random Variable. LetX be an exponential random variable with parameter λ:

fX(x) = λe−λx, x ≥ 0.

Then,

M(s) =λ

∫ ∞

0

esx

e−λx

dx

∫ ∞

0

e(s−λ)x dx

=λe(s−λ)x

s− λ

∣∣∣∣∞

0

(if s < λ)

λ − s.

The above calculation and the formula for M (s) is correct only if the integrande(s−λ)x decays as x increases, which is the case if and only if s < λ; otherwise, theintegral is infinite.

It is important to realize that the transform is not a number but rather afunction of a free variable or parameter s. Thus, we are dealing with a transfor-mation that starts with a function, e.g., a PDF fX(x) (which is a function of afree variable x) and results in a new function, this time of a real parameter s.Strictly speaking, M(s) is only defined for those values of s for which E[esX ] isfinite, as noted in the preceding example.

Example 4.4. The Transform of a Linear Function of a Random Variable.Let MX(s) be the transform associated with a random variable X. Consider a newrandom variable Y = aX + b. We then have

MY (s) = E[es(aX+b)] = esbE[esaX ] = esbMX(sa).

For example, if X is exponential with parameter λ = 1, so that MX(s) = 1/(1− s),and if Y = 2X + 3, then

MY (s) = e3s 1

1− 2s.

Page 227: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.1 Transforms 5

Example 4.5. The Transform of a Normal Random Variable. Let Xbe a normal random variable with mean µ and variance σ2. To calculate thecorresponding transform, we first consider the special case of the standard normalrandom variable Y , where µ = 0 and σ2 = 1, and then use the formula of thepreceding example. The PDF of the standard normal is

fY (y) =1√2π

e−y2/2,

and its transform is

MY (s) =

∫ ∞

−∞

1√2π

e−y2/2 esy dy

=1√2π

∫ ∞

−∞e−(y2/2)+sydy

= es2/2 1√2π

∫ ∞

−∞e−(y2/2)+sy−(s2/2)dy

= es2/2 1√2π

∫ ∞

−∞e−(y−s)2/2dy

= es2/2,

where the last equality follows by using the normalization property of a normalPDF with mean s and unit variance.

A general normal random variable with mean µ and variance σ2 is obtainedfrom the standard normal via the linear transformation

X = σY + µ.

The transform of the standard normal is MY (s) = es2/2, as verified above. Byapplying the formula of Example 4.4, we obtain

MX(s) = esµMY (sσ) = eσ2s2

2 +µs.

From Transforms to Moments

The reason behind the alternative name “moment generating function” is thatthe moments of a random variable are easily computed once a formula for theassociated transform is available. To see this, let us take the derivative of bothsides of the definition

M(s) =

∫ ∞

−∞esxfX(x) dx,

Page 228: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

6 Further Topics on Random Variables and Expectations Chap. 4

with respect to s. We obtain

d

dsM(s) =

d

ds

∫ ∞

−∞esxfX(x) dx

=

∫ ∞

−∞

d

dsesxfX(x) dx

=

∫ ∞

−∞xesxfX(x) dx.

This equality holds for all values of s. By considering the special case wheres = 0, we obtain†

d

dsM(s)

∣∣∣∣s=0

=

∫ ∞

−∞xfX(x) dx = E[X ].

More generally, if we differentiate n times the function M(s) with respect to s,a similar calculation yields

dn

dsnM(s)

∣∣∣∣s=0

=

∫ ∞

−∞xnfX(x) dx = E[Xn].

Example 4.6. We saw earlier (Example 4.1) that the PMF

pX(x) =

1/2, if x = 2,1/6, if x = 3,1/3, if x = 5,

has the transform

M (s) =1

2e2s +

1

6e3s +

1

3e5s.

Thus,

E[X] =d

dsM (s)

∣∣∣s=0

=1

22e2s +

1

63e3s +

1

35e5s

∣∣∣s=0

=1

2· 2 +

1

6· 3 +

1

3· 5

=19

6.

† This derivation involves an interchange of differentiation and integration. Theinterchange turns out to be justified for all of the applications to be considered inthis book. Furthermore, the derivation remains valid for general random variables,including discrete ones. In fact, it could be carried out more abstractly, in the form

d

dsM(s) =

d

dsE[esX ] = E

[d

dsesX

]= E[XesX ],

leading to the same conclusion.

Page 229: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.1 Transforms 7

Also,

E[X2] =

d2

ds2M (s)

∣∣∣∣s=0

=1

24e

2s+

1

69e

3s+

1

325e

5s∣∣∣s=0

=1

2· 4 +

1

6· 9 +

1

3· 25

=71

6.

For an exponential random variable with PDF

fX(x) = λe−λx

, x ≥ 0,

we found earlier that

M (s) =λ

λ− s.

Thus,d

dsM(s) =

λ

(λ − s)2,

d2

ds2M (s) =

(λ − s)3.

By setting s = 0, we obtain

E[X] =1

λ, E[X

2] =

2

λ2,

which agrees with the formulas derived in Chapter 3.

Inversion of Transforms

A very important property of transforms is the following.

Inversion Property

The transform MX(s) completely determines the probability law of the ran-dom variable X. In particular, if MX(s) = MY (s) for all s, then the randomvariables X and Y have the same probability law.

This property is a rather deep mathematical fact that we will use fre-quently.† There exist explicit formulas that allow us to recover the PMF orPDF of a random variable starting from the associated transform, but they arequite difficult to use. In practice, transforms are usually inverted by “patternmatching,” based on tables of known distribution-transform pairs. We will seea number of such examples shortly.

† In fact, the probability law of a random variable is completely determined even

if we only know the transform M (s) for values of s in some interval of positive length.

Page 230: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

8 Further Topics on Random Variables and Expectations Chap. 4

Example 4.7. We are told that the transform associated with a random variableX is

M(s) =1

4e−s

+1

2+

1

8e4s

+1

8e5s

.

Since M(s) is a sum of terms of the form esx, we can compare with the generalformula

M (s) =∑

x

esxpX(x),

and infer that X is a discrete random variable. The different values that X cantake can be read from the corresponding exponents and are −1, 0, 4, and 5. Theprobability of each value x is given by the coefficient multiplying the correspondingesx term. In our case, P(X = −1) = 1/4, P(X = 0) = 1/2, P(X = 4) = 1/8,P(X = 5) = 1/8.

Generalizing from the last example, the distribution of a finite-valued dis-crete random variable can be always found by inspection of the correspondingtransform. The same procedure also works for discrete random variables withan infinite range, as in the example that follows.

Example 4.8. The Transform of a Geometric Random Variable. We aretold that the transform associated with random variable X is of the form

M(s) =pes

1− (1− p)es,

where p is a constant in the range 0 < p < 1. We wish to find the distribution ofX . We recall the formula for the geometric series:

1

1− α= 1 + α + α

2+ · · · ,

which is valid whenever |α| < 1. We use this formula with α = (1− p)es, and for ssufficiently close to zero so that (1− p)es < 1. We obtain

M(s) = pes(1 + (1− p)e

s+ (1− p)

2e2s

+ (1− p)3e3s

+ · · ·)

.

As in the previous example, we infer that this is a discrete random variable thattakes positive integer values. The probability P(X = k) is found by reading thecoefficient of the term eks. In particular, P(X = 1) = p, P(X = 2) = p(1− p), etc.,and

P(X = k) = p(1− p)k−1

, k = 1, 2, . . .

We recognize this as the geometric distribution with parameter p.Note that

d

dsM(s) =

pes

1 − (1− p)es+

(1− p)pes

(1− (1− p)es)2.

Page 231: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.1 Transforms 9

If we set s = 0, the above expression evaluates to 1/p, which agrees with the formulafor E[X] derived in Chapter 2.

Example 4.9. The Transform of a Mixture of Two Distributions. Theneighborhood bank has three tellers, two of them fast, one slow. The time to assista customer is exponentially distributed with parameter λ = 6 at the fast tellers,and λ = 4 at the slow teller. Jane enters the bank and chooses a teller at random,each one with probability 1/3. Find the PDF of the time it takes to assist Jane andits transform.

We have

fX(x) =2

3· 6e−6x +

1

3· 4e−4x, x ≥ 0.

Then,

M(s) =

∫ ∞

0

esx

(2

36e−6x

+1

34e−4x

)dx

=2

3

∫ ∞

0

esx6e−6x dx +1

3

∫ ∞

0

esx4e−4x dx

=2

3· 6

6− s+

1

3· 4

4− s(for s < 4).

More generally, let X1, . . . ,Xn be continuous random variables with PDFsfX1 , . . . fXn , and let Y be a random variable, which is equal to Xi with probabilitypi. Then,

fY (y) = p1fX1 (y) + · · ·+ pnfXn(y),

and

MY (s) = p1MX1 (s) + · · ·+ pnMXn (s).

The steps in this problem can be reversed. For example, we may be told thatthe transform associated with a random variable Y is of the form

1

2· 1

2 − s+

3

4· 1

1 − s.

We can then rewrite it as

1

4· 2

2 − s+

3

4· 1

1 − s,

and recognize that Y is the mixture of two exponential random variables withparameters 2 and 1, which are selected with probabilities 1/4 and 3/4, respectively.

Page 232: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

10 Further Topics on Random Variables and Expectations Chap. 4

Sums of Independent Random Variables

Transform methods are particularly convenient when dealing with a sum of ran-dom variables. This is because it turns out that addition of independent randomvariables corresponds to multiplication of transforms, as we now show.

Let X and Y be independent random variables, and let W = X + Y . Thetransform associated with W is, by definition,

MW (s) = E[esW ] = E[es(X+Y )] = E[esXesY ].

Consider a fixed value of the parameter s. Since X and Y are independent,esX and esY are independent random variables. Hence, the expectation of theirproduct is the product of the expectations, and

MW (s) = E[esX ]E[esY ] = MX (s)MY (s).

By the same argument, if X1, . . . , Xn is a collection of independent randomvariables, and

W = X1 + · · ·+ Xn,

thenMW (s) = MX1(s) · · ·MXn(s).

Example 4.10. The Transform of the Binomial. Let X1, . . . , Xn be inde-pendent Bernoulli random variables with a common parameter p. Then,

MXi (s) = (1− p)e0s + pe1s = 1− p + pes, for all i.

The random variable Y = X1 + · · ·+ Xn is binomial with parameters n and p. Itstransform is given by

MY (s) =(1− p + pes

)n.

Example 4.11. The Sum of Independent Poisson Random Variables isPoisson. Let X and Y be independent Poisson random variables with means λand µ, respectively, and let W = X + Y . Then,

MX(s) = eλ(es−1)

, MY (s) = eµ(es−1)

,

andMW (s) = MX(s)MY (s) = eλ(es−1)eµ(es−1) = e(λ+µ)(es−1).

Thus, W has the same transform as a Poisson random variable with mean λ + µ.By the uniqueness property of transforms, W is Poisson with mean λ + µ.

Page 233: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.1 Transforms 11

Example 4.12. The Sum of Independent Normal Random Variables isNormal. Let X and Y be independent normal random variables with means µx,µy, and variances σ2

x, σ2y, respectively. Let W = X + Y . Then,

MX(s) = eσ2

xs2

2 +µxs, MY (s) = eσ2

ys2

2 +µys,

and

MW (s) = e(σ2

x+σ2y)s2

2 +(µx+µy)s.

Thus, W has the same transform as a normal random variable with mean µx + µy

and variance σ2x +σ2

y. By the uniqueness property of transforms, W is normal withthese parameters.

Summary of Transforms and their Properties

• The transform associated with the distribution of a random variableX is given by

MX(s) = E[esX ] =

x

esxpX (x), x discrete,

∫ ∞

−∞esxfX(x) dx, x continuous.

• The distribution of a random variable is completely determined by thecorresponding transform.

• Moment generating properties:

MX(0) = 1,d

dsMX(s)

∣∣∣∣s=0

= E[X],dn

dsnMX(s)

∣∣∣∣s=0

= E[Xn].

• If Y = aX + b, then MY (s) = esbMX(as).

• If X and Y are independent, then MX+Y (s) = MX(s)MY (s).

We have derived formulas for the transforms of a few common randomvariables. Such formulas can be derived with a moderate amount of algebra formany other distributions. Some of the most useful ones are summarized in thetables that follow.

Transforms of Joint Distributions

If two random variables X and Y are described by some joint distribution (e.g., ajoint PDF), then each one is associated with a transform MX(s) or MY (s). These

Page 234: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

12 Further Topics on Random Variables and Expectations Chap. 4

Transforms for Common Discrete Random Variables

Bernoulli(p)

pX (k) =

p, if k = 1,1− p, if k = 0.

MX(s) = 1− p + pes.

Binomial(n, p)

pX(k) =

(n

k

)pk(1− p)n−k, k = 0, 1, . . . , n.

MX(s) = (1− p + pes)n.

Geometric(p)

pX(k) = p(1− p)k−1, k = 1, 2, . . . MX (s) =pes

1− (1− p)es.

Poisson(λ)

pX(k) =e−λλk

k!, k = 0,1, . . . MX (s) = eλ(es−1).

Uniform(a, b)

pX(k) =1

b− a + 1, k = a, a + 1, . . . , b.

MX (s) =eas

b− a + 1

e(b−a+1)s − 1

es − 1.

are the transforms of the marginal distributions and do not convey information onthe dependence between the two random variables. Such information is containedin a multivariate transform, which we now define.

Consider n random variables X1, . . . , Xn related to the same experiment.Let s1, . . . , sn be scalar free parameters. The associated multivariate transformis a function of these n parameters and is defined by

MX1,...,Xn(s1, . . . , sn) = E[esX1+···+snXn

].

The inversion property of transforms discussed earlier extends to the multi-variate case. That is, if Y1, . . . , Yn is another set of random variables andMX1,...,Xn(s1, . . . , sn), MY1,...,Yn(s1, . . . , sn) are the same functions of s1, . . . , sn,

Page 235: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.2 Sums of Independent Random Variables — Convolutions 13

Transforms for Common Continuous Random Variables

Uniform(a, b)

fX(x) =1

b− a, a ≤ x ≤ b. MX(s) =

1

b− a

esb − esa

s.

Exponential(λ)

fX (x) = λe−λx, x ≥ 0. MX(s) =λ

λ− s, (s > λ).

Normal(µ, σ2)

fX(x) =1

σ√

2πe−(x−µ)2/2σ2

, −∞ < x < ∞. MX(s) = eσ2s2

2 +µs.

then the joint distribution of X1, . . . , Xn is the same as the joint distribution ofY1, . . . , Yn.

4.2 SUMS OF INDEPENDENT RANDOM VARIABLES— CONVOLUTIONS

If X and Y are independent random variables, the distribution of their sumW = X + Y can be obtained by computing and then inverting the transformMW (s) = MX (s)MY (s). But it can also be obtained directly, using the methoddeveloped in this section.

The Discrete Case

Let W = X+Y , where X and Y are independent integer-valued random variableswith PMFs pX (x) and pY (y). Then, for any integer w,

pW (w) =P(X + Y = w)

=∑

(x,y): x+y=w

P(X = x and Y = y)

=∑

x

P(X = x and Y = w − x)

=∑

x

pX(x)pY (w − x).

Page 236: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

14 Further Topics on Random Variables and Expectations Chap. 4

x

y

..

..

.

.

(3,0)

(2,1)

(1,2)

(0,3)

Figure 4.2: The probability pW (3) that X+Y = 3 is the sum of the probabilitiesof all pairs (x, y) such that x + y = 3, which are the points indicated in thefigure. The probability of a generic such point is of the form pX,Y (x, 3 − x) =pX(x)pY (3− x).

The resulting PMF pW (w) is called the convolution of the PMFs of X and Y .See Fig. 4.2 for an illustration.

Example 4.13. Let X and Y be independent and have PMFs given by

pX(x) =

13 if x = 1, 2, 3,0 otherwise,

pY (y) =

12 if x = 0,13

if x = 1,16 if x = 2,0 otherwise.

To calculate the PMF of W = X + Y by convolution, we first note that the rangeof possible values of w are the integers from the range [1, 5]. Thus we have

pW (w) = 0 if w 6= 1, 2, 3, 4, 5.

We calculate pW (w) for each of the values w = 1, 2, 3, 4, 5 using the convolutionformula. We have

pW (1) =∑

x

pX(x)pY (1− x) = pX(1) · pY (0) =1

3· 1

2=

1

6,

where the second equality above is based on the fact that for x 6= 1 either pX(x) orpY (1− x) (or both) is zero. Similarly, we obtain

pW (2) = pX(1) · pY (1) + pX(2) · pY (0) =1

3· 1

3+

1

3· 1

2=

5

18,

pW (3) = pX(1) · pY (2) + pX(2) · pY (1) + pX(3) · pY (0) =1

3· 1

6+

1

3· 1

3+

1

3· 1

2=

1

3,

pW (4) = pX(2) · pY (2) + pX(3) · pY (1) =1

3· 1

6+

1

3· 1

3=

1

6,

pW (5) = pX(3) · pY (2) =1

3· 1

6=

1

18.

Page 237: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.2 Sums of Independent Random Variables — Convolutions 15

The Continuous Case

Let X and Y be independent continuous random variables with PDFs fX(x) andfY (y). We wish to find the PDF of W = X + Y . Since W is a function of tworandom variables X and Y , we can follow the method of Chapter 3, and startby deriving the CDF FW (w) of W . We have

FW (w) = P(W ≤ w)

= P(X + Y ≤ w)

=

∫ ∞

x=−∞

∫ w−x

y=−∞fX(x)fY (y) dy dx

=

∫ ∞

x=−∞fX(x)

[∫ w−x

y=−∞fY (y) dy

]dx

=

∫ ∞

x=−∞fX(x)FY (w − x) dx.

The PDF of W is then obtained by differentiating the CDF:

fW (w) =dFW

dw(w)

=d

dw

∫ ∞

x=−∞fX (x)FY (w − x) dx

=

∫ ∞

x=−∞fX(x)

dFY

dw(w − x) dx

=

∫ ∞

x=−∞fX(x)fY (w − x) dx.

This formula is entirely analogous to the formula for the discrete case, exceptthat the summation is replaced by an integral and the PMFs are replaced byPDFs. For an intuitive understanding of this formula, see Fig. 4.3.

Example 4.14. The random variables X and Y are independent and uniformlydistributed in the interval [0, 1]. The PDF of W = X + Y is

fW (w) =

∫ ∞

−∞fX(x)fY (w − x)dx.

The integrand fX(x)fY (w − x) is nonzero (and equal to 1) for 0 ≤ x ≤ 1 and0 ≤ w − x ≤ 1. Combining these two inequalities, the integrand is nonzero formax0, w − 1 ≤ x ≤ min1, w. Thus,

fW (w) =

min1, w −max0, w − 1, 0 ≤ w ≤ 2,0, otherwise,

Page 238: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

16 Further Topics on Random Variables and Expectations Chap. 4

x

y

x + y = w

w

w

x + y = w + δ

w + δ

Figure 4.3: Illustration of the convolution formula for the case of continuousrandom variables (compare with Fig. 4.2). For small δ, the probability of thestrip indicated in the figure is P(w ≤ X + Y ≤ w + δ) ≈ fW (w) · δ. Thus,

fW (w) · δ =P(w ≤ X + Y ≤ w + δ)

=

∫ ∞

x=−∞

∫ w−x+δ

y=w−x

fX (x)fY (y) dy dx

≈∫ ∞

x=−∞fX (x)fY (w− x)δ dx.

The desired formula follows by canceling δ from both sides.

w

fW(w)

2

1

Figure 4.4: The PDF of the sum of two independent uniform random variablesin [0, 1].

which has the triangular shape shown in Fig. 4.4.

The calculation in the last example was based on a literal application of theconvolution formula. The most delicate step was to determine the correct limitsfor the integration. This is often tedious and error prone, but can be bypassedusing a graphical method described next.

Page 239: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.3 Conditional Expectation as a Random Variable 17

Graphical Calculation of Convolutions

We will use a dummy variable t as the argument of the different functions in-volved in this discussion; see also Fig. 4.5. Consider a PDF fX(t) which is zerooutside the range a ≤ t ≤ b and a PDF fY (t) which is zero outside the rangec ≤ t ≤ d. Let us fix a value w, and plot fY (w − t) as a function of t. This plothas the same shape as the plot of fY (t) except that it is first “flipped” and thenshifted by an amount w. (If w > 0, this is a shift to the right, if w < 0, this is ashift to the left.) We then place the plots of fX (t) and fY (w− t) on top of eachother. The value of fW (w) is equal to the integral of the product of these twoplots. By varying the amount w by which we are shifting, we obtain fW (w) forany w.

w − cw − d

a b

fX(t)

c d

fY(t)

− c− d

a b

fY(w − t ) fY(− t)

t t

t t

t

fY(w − t )fX(t)

Figure 4.5: Illustration of the convolution calculation. For the value of w underconsideration, fW (w) is equal to the integral of the function shown in the lastplot.

4.3 CONDITIONAL EXPECTATION AS A RANDOM VARIABLE

The value of the conditional expectation E[X |Y = y] of a random variable Xgiven another random variable Y depends on the realized experimental value yof Y . This makes E[X | Y ] a function of Y , and therefore a random variable. Inthis section, we study the expectation and variance of E[X | Y ]. In the process,

Page 240: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

18 Further Topics on Random Variables and Expectations Chap. 4

we obtain some useful formulas (the law of iterated expectations and thelaw of conditional variances) that are often convenient for the calculation ofexpected values and variances.

Recall that the conditional expectation E[X | Y = y] is defined by

E[X | Y = y] =∑

x

xpX|Y (x | y), (discrete case),

and

E[X | Y = y] =

∫ ∞

−∞xfX|Y (x | y) dx, (continuous case).

Once a value of y is given, the above summation or integration yields a numericalvalue for E[X |Y = y].

Example 4.15. Let the random variables X and Y have a joint PDF whichis equal to 2 for (x, y) belonging to the triangle indicated in Fig. 4.6(a), and zeroeverywhere else. In order to compute E[X |Y = y], we first need to obtain theconditional density of X given Y = y.

x

y

1

1

fX,Y(x ,y) = 2

x 1

fX|Y(x |y )

1 − y

1 − y

1

(a) (b)

1 − y

y

Figure 4.6: (a) The joint PDF in Example 4.15. (b) The conditional densityof X .

We have

fY (y) =

∫ ∞

−∞fX,Y (x, y)dx =

∫ 1−y

0

2 dx = 2(1− y), 0 ≤ y ≤ 1,

and

fX|Y (x | y) =fX,Y (x, y)

fY (y)=

1

1 − y, 0 ≤ x ≤ 1− y.

The conditional density is shown in Fig. 4.6(b).

Page 241: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.3 Conditional Expectation as a Random Variable 19

Intuitively, since the joint PDF is constant, the conditional PDF (which is a“slice” of the joint, at some fixed y) is also a constant. Therefore, the conditionalPDF must be a uniform distribution. Given that Y = y, X ranges from 0 to 1− y.Therefore, for the PDF to integrate to 1, its height must be equal to 1/(1− y), inagreement with Fig. 4.6(b).

For y > 1 or y < 0, the conditional PDF is undefined, since these values ofy are impossible. For y = 1, X must be equal to 0, with certainty, and E[X |Y =1] = 0.

For 0 ≤ y < 1, the conditional mean E[X | Y = y] is the expectation of theuniform PDF in Fig. 4.6(b), and we have

E[X | Y = y] =1 − y

2, 0 ≤ y < 1.

Since E[X |Y = 1] = 0, the above formula is also valid when y = 1. The conditionalexpectation is undefined when y is outside [0, 1].

For any number y, E[X |Y = y] is also a number. As y varies, so doesE[X | Y = y], and we can therefore view E[X | Y = y] as a function of y. Sincey is the experimental value of the random variable Y , we are dealing with afunction of a random variable, hence a new random variable. More precisely, wedefine E[X |Y ] to be the random variable whose value is E[X | Y = y] when theoutcome of Y is y.

Example 4.15. (continued) We saw that E[X | Y = y] = (1 − y)/2. Hence,E[X |Y ] is the random variable (1− Y )/2:

E[X |Y ] =1 − Y

2.

Since E[X | Y ] is a random variable, it has an expectation E[E[X |Y ]

]of

its own. Applying the expected value rule, this is given by

E[E[X |Y ]

]=

y

E[X | Y = y]pY (y), Y discrete,

∫ ∞

−∞E[X |Y = y]fY (y) dy, Y continuous.

Both expressions in the right-hand side should be familiar from Chapters 2 and3, respectively. By the corresponding versions of the total expectation theorem,they are equal to E[X]. This brings us to the following conclusion, which isactually valid for every type of random variable Y (discrete, continuous, mixed,etc.), as long as X has a well-defined and finite expectation E[X].

Law of iterated expectations: E[E[X | Y ]

]= E[X].

Page 242: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

20 Further Topics on Random Variables and Expectations Chap. 4

Example 4.15 (continued) In Example 4.15, we found E[X |Y ] = (1 − Y )/2[see Fig. 4.6(b)]. Taking expectations of both sides, and using the law of iteratedexpectations to evaluate the left-hand side, we obtain E[X] =

(1−E[Y ]

)/2. Because

of symmetry, we must have E[X ] = E[Y ]. Therefore, E[X] =(1− E[X ]

)/2, which

yields E[X ] = 1/3. In a slightly different version of this example, where there is nosymmetry between X and Y , we would use a similar argument to express E[Y ].

Example 4.16. We start with a stick of length `. We break it at a point whichis chosen randomly and uniformly over its length, and keep the piece that containsthe left end of the stick. We then repeat the same process on the stick that wewere left with. What is the expected length of the stick that we are left with, afterbreaking twice?

Let Y be the length of the stick after we break for the first time. Let X bethe length after the second time. We have E[X | Y ] = Y/2, since the breakpoint ischosen uniformly over the length Y of the remaining stick. For a similar reason, wealso have E[Y ] = `/2. Thus,

E[X] = E[E[X | Y ]

]= E

[Y

2

]=

E[Y ]

2=

`

4.

Example 4.17. Averaging Quiz Scores by Section. A class has n studentsand the quiz score of student i is xi. The average quiz score is

m =1

n

n∑

i=1

xi.

The class consists of S sections, with ns students in section s. The average scorein section s is

ms =1

ns

stdnts. i in sec. s

xi.

The average score over the whole class can be computed by taking the average scorems of each section, and then forming a weighted average; the weight given to sections is proportional to the number of students in that section, and is ns/n. We verifythat this gives the correct result:

S∑

s=1

ns

nms =

S∑

s=1

ns

n· 1

ns

stdnts. i in sec. s

xi

=1

n

S∑

s=1

stdnts. i in sec. s

xi

=1

n

n∑

i=1

xi.

= m.

Page 243: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.3 Conditional Expectation as a Random Variable 21

How is this related to conditional expectations? Consider an experiment inwhich a student is selected at random, each student having probability 1/n of beingselected. Consider the following two random variables:

X = quiz score of a student,

Y = section of a student, (Y ∈ 1, . . . , S).

We then haveE[X] = m.

Conditioning on Y = s is the same as assuming that the selected student isin section s. Conditional on that event, every student in that section has the sameprobability 1/ns of being chosen. Therefore,

E[X | Y = s] =1

ns

stdnts. i in sec. s

xi = ms.

A randomly selected student belongs to section s with probability ns/n, i.e., P(Y =s) = ns/n. Hence,

E[E[X |Y ]

]=

S∑

s=1

E[X | Y = s]P(Y = s) =

S∑

s=1

ns

nms.

As shown earlier, this is the same as m. Thus, averaging by section can be viewedas a special case of the law of iterated expectations.

Example 4.18. Forecast Revisions. Let Y be the sales of a company in thefirst semester of the coming year, and let X be the sales over the entire year. Thecompany has constructed a statistical model of sales, and so the joint distribution ofX and Y is assumed to be known. In the beginning of the year, the expected valueE[X ] serves as a forecast of the actual sales X . In the middle of the year, the firstsemester sales have been realized and the experimental value of the random value Yis now known. This places us in a new “universe,” where everything is conditionedon the realized value of Y . We then consider the mid-year revised forecast of yearlysales, which is E[X |Y ].

We view E[X | Y ] − E[X ] as the forecast revision, in light of the mid-yearinformation. The law of iterated expectations implies that

E[E[X |Y ]− E[X]

]= 0.

This means that, in the beginning of the year, we do not expect our forecast tobe revised in any specific direction. Of course, the actual revision will usually bepositive or negative, but the probabilities are such that it is zero on the average.This is quite intuitive. For example, if a positive revision was expected, the originalforecast should have been higher in the first place.

Page 244: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

22 Further Topics on Random Variables and Expectations Chap. 4

The Conditional Variance

The conditional distribution of X given Y = y has a mean, which is E[X |Y = y],and by the same token, it also has a variance. This is defined by the same formulaas the unconditional variance, except that everything is conditioned on Y = y:

var(X | Y = y) = E[(

X −E[X | Y = y])2 ∣∣ Y = y

].

Note that the conditional variance is a function of the experimental value y ofthe random variable Y . Hence, it is a function of a random variable, and is itselfa random variable that will be denoted by var(X | Y ).

Arguing by analogy to the law of iterated expectations, we may conjecturethat the expectation of the conditional variance var(X |Y ) is related to theunconditional variance var(X). This is indeed the case, but the relation is morecomplex.

Law of Conditional Variances:

var(X) = E[var(X | Y )

]+ var

(E[X | Y ]

)

To verify the law of conditional variances, we start with the identity

X − E[X] =(X −E[X | Y ]

)+

(E[X | Y ]− E[X]

).

We square both sides and then take expectations to obtain

var(X) = E[(

X −E[X])2

]

= E[(

X −E[X | Y ])2

]+ E

[(E[X | Y ]−E[X]

)2]

+ 2E[(

X − E[X | Y ])(

E[X | Y ]− E[X])]

.

Using the law of iterated expectations, the first term in the right-hand side ofthe above equation can be written as

E[E

[(X − E[X |Y ]

)2 ∣∣ Y] ]

,

which is the same as E[var(X | Y )

]. The second term is equal to var

(E[X |Y ]

),

since E[X] is the mean of E[X | Y ]. Finally, the third term is zero, as we nowshow. Indeed, if we define h(Y ) = 2

(E[X | Y ]− E[X]

), the third term is

E[(

X − E[X | Y ])h(Y )

]= E

[Xh(Y )

]− E

[E[X |Y ]h(Y )

]

= E[Xh(Y )

]− E

[E

[Xh(Y ) | Y

]]

= E[Xh(Y )

]− E

[Xh(Y )

]

= 0.

Page 245: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.3 Conditional Expectation as a Random Variable 23

Example 4.16. (continued) Consider again the problem where we break twicea stick of length `, at randomly chosen points, with Y being the length of the stickafter the first break and X being the length after the second break. We calculatedthe mean of X as `/4, and now let us use the law of conditional variances to calculatevar(X). We have E[X |Y ] = Y/2, so since Y is uniformly distributed between 0and `,

var(E[X |Y ]

)= var(Y/2) =

1

4var(Y ) =

1

4· `2

12=

`2

48.

Also, since X is uniformly distributed between 0 and Y , we have

var(X |Y ) =Y 2

12.

Thus, since Y is uniformly distributed between 0 and `,

E[var(X | Y )

]=

1

12

∫ `

0

1

`y2dy =

1

12

1

3`y3

∣∣`0

=`2

36.

Using now the law of conditional variances, we obtain

var(X) = E[var(X | Y )

]+ var

(E[X | Y ]

)=

`2

48+

`2

36=

7`2

144.

Example 4.19. Averaging Quiz Scores by Section – Variance. The settingis the same as in Example 4.17 and we consider the random variables

X = quiz score of a student,

Y = section of a student, (Y ∈ 1, . . . , S).

Let ns be the number of students in section s, and let n be the total number ofstudents. We interpret the different quantities in the formula

var(X) = E[var(X |Y )

]+ var

(E[X |Y ]

).

In this context, var(X |Y = s) is the variance of the quiz scores within sec-tion s. Then, E

[var(X |Y )

]is the average of the section variances. This latter

expectation is an average over the probability distribution of Y , i.e.,

E[var(X | Y )

]=

S∑

s=1

ns

nvar(X |Y = s).

Recall that E[X | Y = s] is the average score in section s. Then, var(E[X | Y ]

)

is a measure of the variability of the averages of the different sections. The law ofconditional variances states that the total quiz score variance can be broken intotwo parts:

Page 246: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

24 Further Topics on Random Variables and Expectations Chap. 4

(a) The average score variability E[var(X |Y )

]within individual sections.

(b) The variability var(E[X |Y ]

)between sections.

We have seen earlier that the law of iterated expectations (in the form of thetotal expectation theorem) can be used to break down complicated expectationcalculations, by considering different cases. A similar method applies to variancecalculations.

Example 4.20. Computing Variances by Conditioning. Consider a con-tinuous random variable X with the PDF given in Fig. 4.7. We define an auxiliaryrandom variable Y as follows:

Y =

1, if x < 1,2, of x ≥ 1.

Here, E[X |Y ] takes the values 1/2 and 3/2, with probabilities 1/3 and 2/3, respec-tively. Thus, the mean of E[X |Y ] is 7/6. Therefore,

var(E[X |Y ]

)=

1

3

(1

2− 7

6

)2

+2

3

(3

2− 7

6

)2

=2

9.

x 1

fX(x )

2

1/3

2/3

Figure 4.7: The PDF in Example 4.20.

Conditioned on either value of Y , X is uniformly distributed on a unit lengthinterval. Therefore, var(X |Y = y) = 1/12 for each of the two possible values of y,and E

[var(X | Y )

]= 1/12. Putting everything together, we obtain

var(X) = E[var(X |Y )

]+ var

(E[X |Y ]

)=

1

12+

2

9=

11

36.

Page 247: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.4 Sum of a Random Number of Independent Random Variables 25

We summarize the main points in this section.

The Mean and Variance of a Conditional Expectation

• E[X | Y = y] is a number, whose value depends on y.

• E[X | Y ] is a function of the random variable Y , hence a random vari-able. Its experimental value is E[X | Y = y] whenever the experimentalvalue of Y is y.

• E[E[X | Y ]

]= E[X] (law of iterated expectations).

• var(X | Y ) is a random variable whose experimental value is var(X | Y =y), whenever the experimental value of Y is y.

• var(X) = E[var(X | Y )

]+ var

(E[X | Y ]

).

4.4 SUM OF A RANDOM NUMBER OF INDEPENDENT RANDOMVARIABLES

In our discussion so far of sums of random variables, we have always assumedthat the number of variables in the sum is known and fixed, i.e., it is nonrandom.In this section we will consider the case where the number of random variablesbeing added is itself random. In particular, we consider the sum

Y = X1 + · · ·+ XN ,

where N is a random variable that takes nonnegative integer values, and X1, X2, . . .are identically distributed random variables. We assume that N,X1, X2, . . . areindependent, meaning that any finite subcollection of these random variables areindependent.

We first note that the randomness of N can affect significantly the characterof the random sum Y = X1 + · · · + XN . In particular, the PMF/PDF of Y =∑N

i=1 Yi is much different from the PMF/PDF of the sum Y =∑E[N]

i=1 Yi whereN has been replaced by its expected value (assuming that E[N ] is integer). Forexample, let Xi be uniformly distributed in the interval [0,1], and let N beequal to 1 or 3 with probability 1/2 each. Then the PDF of the random sum Ytakes values in the interval [0,3], whereas if we replace N by its expected valueE[N ] = 2, the sum Y = X1 +X2 takes values in the interval [0,2]. Furthermore,using the total probability theorem, we see that the PDF of Y is a mixture ofthe uniform PDF and the PDF of X1 + X2 + X3, and has considerably differentcharacter than the triangular PDF of Y = X1 + X2 which is given in Fig. 4.4.

Let us denote by µ and σ2 the common mean and the variance of the Xi.We wish to derive formulas for the mean, variance, and the transform of Y . The

Page 248: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

26 Further Topics on Random Variables and Expectations Chap. 4

method that we follow is to first condition on the event N = n, under which wehave the sum of a fixed number of random of random variables, a case that wealready know how to handle.

Fix some number n. The random variable X1 + · · ·+ Xn is independent ofN and, therefore, independent of the event N = n. Hence,

E[Y |N = n] = E[X1 + · · ·+ XN |N = n]

= E[X1 + · · ·+ Xn |N = n]

= E[X1 + · · ·+ Xn]

= nµ.

This is true for every nonnegative integer n and, therefore,

E[Y |N ] = Nµ.

Using the law of iterated expectations, we obtain

E[Y ] = E[E[Y |N ]

]= E[µN ] = µE[N ].

Similarly,

var(Y |N = n) = var(X1 + · · ·+ XN |N = n)

= var(X1 + · · ·+ Xn)

= nσ2.

Since this is true for every nonnegative integer n, the random variable var(Y |N)is equal to Nσ2. We now use the law of conditional variances to obtain

var(Y ) = E[var(Y |N )

]+ var

(E[Y |N ]

)

= E[N ]σ2 + var(Nµ)

= E[N ]σ2 + µ2var(N).

The calculation of the transform proceeds along similar lines. The trans-form associated with Y , conditional on N = n, is E[esY |N = n]. However, condi-tioned on N = n, Y is the sum of the independent random variables X1, . . . , Xn,and

E[esY |N = n]= E[esX1 · · · esXN |N = n

]= E

[esX1 · · · esXn

]

= E[esX1 ] · · ·E[esXn ] =(MX(s)

)n.

Using the law of iterated expectations, the (unconditional) transform associatedwith Y is

E[esY ] = E[E[esY |N ]

]= E

[(MX(s)

)N]=

∞∑

n=0

(MX(s))npN (n).

Page 249: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.4 Sum of a Random Number of Independent Random Variables 27

This is similar to the transform MN (s) = E[esN ] associated with N , except thates is replaced by MX(s).

Example 4.21. A remote village has three gas stations, and each one of themis open on any given day with probability 1/2, independently of the others. Theamount of gas available in each gas station is unknown and is uniformly distributedbetween 0 and 1000 gallons. We wish to characterize the distribution of the totalamount of gas available at the gas stations that are open.

The number N of open gas stations is a binomial random variable with p =1/2 and the corresponding transform is

MN (s) = (1− p + pes)3 =1

8(1 + es)3.

The transform MX(s) associated with the amount of gas available in an open gasstation is

MX(s) =e1000s − 1

1000s.

The transform associated with the total amount Y available is the same as MN (s),except that each occurrence of es is replaced with MX(s), i.e.,

MY (s) =1

8

(1 +

(e1000s − 1

1000s

))3

.

Example 4.22. Sum of a Geometric Number of Independent ExponentialRandom Variables. Jane visits a number of bookstores, looking for Great Ex-pectations. Any given bookstore carries the book with probability p, independentlyof the others. In a typical bookstore visited, Jane spends a random amount of time,exponentially distributed with parameter λ, until she either finds the book or shedecides that the bookstore does not carry it. Assuming that Jane will keep visitingbookstores until she buys the book and that the time spent in each is independentof everything else, we wish to determine the mean, variance, and PDF of the totaltime spent in bookstores.

The total number N of bookstores visited is geometrically distributed with pa-rameter p. Hence, the total time Y spent in bookstores is the sum of a geometricallydistributed number N of independent exponential random variables X1,X2, . . .. Wehave

E[Y ] = E[N ]E[X ] =1

p· 1

λ.

Using the formulas for the variance of geometric and exponential random variables,we also obtain

var(Y ) = E[N ]var(X) + (E[X])2var(N ) =

1

p· 1

λ2+

1

λ2· 1 − p

p2=

1

λ2p2.

Page 250: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

28 Further Topics on Random Variables and Expectations Chap. 4

In order to find the transform MY (s), let us recall that

MX(s) =λ

λ − s, MN (s) =

pes

1− (1− p)es.

Then, MY (s) is found by starting with MN(s) and replacing each occurrence of es

with MX(s). This yields

MY (s) =pMX(s)

1 − (1− p)MX(s)=

λ − s

1− (1− p)λ

λ − s

,

which simplifies to

MY (s) =pλ

pλ− s.

We recognize this as the transform of an exponentially distributed random variablewith parameter pλ, and therefore,

fY (y) = pλe−pλy, y ≥ 0.

This result can be surprising because the sum of a fixed number n of indepen-dent exponential random variables is not exponentially distributed. For example,

if n = 2, the transform associated with the sum is(λ/(λ − s)

)2, which does not

correspond to the exponential distribution.

Example 4.23. Sum of a Geometric Number of Independent GeometricRandom Variables. This example is a discrete counterpart of the preceding one.We let N be geometrically distributed with parameter p. We also let each randomvariable Xi be geometrically distributed with parameter q. We assume that all ofthese random variables are independent. Let Y = X1 + · · · + XN . We have

MN (s) =pes

1 − (1− p)es, MX(s) =

qes

1− (1− q)es.

To determine MY (s), we start with the formula for MN(s) and replace each occur-rence of es with MX(s). This yields

MY (s) =pMX(s)

1− (1− p)MX(s),

and, after some algebra,

MY (s) =pqes

1− (1− pq)es.

We conclude that Y is geometrically distributed, with parameter pq.

Page 251: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.5 Covariance and Correlation 29

Properties of Sums of a Random Number of Independent RandomVariables

Let X1,X2, . . . be random variables with common mean µ and commonvariance σ2. Let N be a random variable that takes nonnegative integervalues. We assume that all of these random variables are independent, andconsider

Y = X1 + · · ·+ XN .

Then,

• E[Y ] = µE[N ].

• var(Y ) = σ2E[N ] + µ2var(N).

• The transform MY (s) is found by starting with the transform MN (s)and replacing each occurrence of es with MX(s).

4.5 COVARIANCE AND CORRELATION

The covariance of two random variables X and Y is denoted by cov(X,Y ), andis defined by

cov(X, Y ) = E[(

X − E[X])(

Y − E[Y ])]

.

When cov(X, Y ) = 0, we say that X and Y are uncorrelated.Roughly speaking, a positive or negative covariance indicates that the val-

ues of X − E[X] and Y − E[Y ] obtained in a single experiment “tend” to havethe same or the opposite sign, respectively (see Fig. 4.8). Thus the sign of thecovariance provides an important qualitative indicator of the relation betweenX and Y .

If X and Y are independent, then

cov(X, Y ) = E[(

X −E[X])(

Y − E[Y ])]

= E[X − E[X]

]E

[Y − E[Y ]

]= 0.

Thus if X and Y are independent, they are also uncorrelated. However, thereverse is not true, as illustrated by the following example.

Example 4.24. The pair of random variables (X, Y ) takes the values (1, 0), (0, 1),(−1, 0), and (0,−1), each with probability 1/4 (see Fig. 4.9). Thus, the marginalPMFs of X and Y are symmetric around 0, and E[X] = E[Y ] = 0. Furthermore,for all possible value pairs (x, y), either x or y is equal to 0, which implies thatXY = 0 and E[XY ] = 0. Therefore,

cov(X,Y ) = E[(

X − E[X])(

Y − E[Y ])]

= E[XY ] = 0,

Page 252: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

30 Further Topics on Random Variables and Expectations Chap. 4

x

y

x

y

(a) (b)

Figure 4.8: Examples of positively and negatively correlated random variables.Here X and Y are uniformly distributed over the ellipses shown. In case (a) thecovariance cov(X, Y ) is negative, while in case (b) it is positive.

x

y

(1,0)(-1,0)

(0,1)

(0,-1)

Figure 4.9: Joint PMF of X and Yfor Example 4.21. Each of the fourpoints shown has probability 1/4. HereX and Y are uncorrelated but not in-dependent.

and X and Y are uncorrelated. However, X and Y are not independent since, forexample, a nonzero value of X fixes the value of Y to zero.

The correlation coefficient ρ of two random variables X and Y that havenonzero variances is defined as

ρ =cov(X,Y )√

var(X)var(Y ).

It may be viewed as a normalized version of the covariance cov(X, Y ), and in factit can be shown that ρ ranges from −1 to 1 (see the end-of-chapter problems).

If ρ > 0 (or ρ < 0), then the values of x − E[X] and y − E[Y ] “tend”to have the same (or opposite, respectively) sign, and the size of |ρ| provides anormalized measure of the extent to which this is true. In fact, always assumingthat X and Y have positive variances, it can be shown that ρ = 1 (or ρ = −1)if and only if there exists a positive (or negative, respectively) constant c suchthat

y − E[Y ] = c(x− E[X ]

), for all possible numerical values (x, y)

Page 253: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.5 Covariance and Correlation 31

(see the end-of-chapter problems). The following example illustrates in part thisproperty.

Example 4.25. Consider n independent tosses of a biased coin with probability ofa head equal to p. Let X and Y be the numbers of heads and of tails, respectively,and let us look at the correlation of X and Y . Here, for all possible pairs of values(x, y), we have x + y = n, and we also have E[X] + E[Y ] = n. Thus,

x− E[X] = −(y − E[Y ]

), for all possible (x, y).

We will calculate the correlation coefficient of X and Y , and verify that it is indeedequal to −1.

We have

cov(X,Y ) = E[(

X − E[X])(

Y − E[Y ])]

= −E[(X − E[X])

2]

= −var(X).

Hence, the correlation coefficient is

ρ(X,Y ) =cov(X,Y )√var(X)var(Y )

=−var(X)√

var(X)var(X)= −1.

The covariance can be used to obtain a formula for the variance of thesum of several (not necessarily independent) random variables. In particular, ifX1,X2, . . . , Xn are random variables with finite variance, we have

var

(n∑

i=1

Xi

)=

n∑

i=1

var(Xi) + 2

n∑

i,j=1i<j

cov(Xi,Xj).

This can be seen from the following calculation, where for brevity, we denoteXi = Xi − E[Xi]:

var

(n∑

i=1

Xi

)= E

(n∑

i=1

Xi

)2

= E

n∑

i=1

n∑

j=1

XiXj

=n∑

i=1

n∑

j=1

E[XiXj ]

=∑

i=1

E[Xi2] + 2

n∑

i,j=1i<j

E[XiXj ]

=

n∑

i=1

var(Xi) + 2

n∑

i,j=1i<j

cov(Xi,Xj).

Page 254: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

32 Further Topics on Random Variables and Expectations Chap. 4

The following example illustrates the use of this formula.

Example 4.26. Consider the hat problem discussed in Section 2.5, where npeople throw their hats in a box and then pick a hat at random. Let us find thevariance of X, the number of people that pick their own hat. We have

X = X1 + · · ·+ Xn,

where Xi is the random variable that takes the value 1 if the ith person selectshis/her own hat, and takes the value 0 otherwise. Noting that Xi is Bernoulli withparameter p = P(Xi = 1) = 1/n, we obtain

var(Xi) =1

n

(1 − 1

n

).

For i 6= j, we have

cov(Xi,Xj) = E[(

Xi − E[Xi])(

Xj − E[Xj ])]

= E[XiXj ] −E[Xi]E[Xj ]

= P(Xi = 1 and Xj = 1)−P(Xi = 1)P(Xj = 1)

= P(Xi = 1)P(Xj = 1 |Xi = 1)−P(Xi = 1)P(Xj = 1)

=1

n

1

n − 1− 1

n2

=1

n2(n− 1).

Therefore

var(X) = var

(n∑

i=1

Xi

)

=

n∑

i=1

var(Xi) + 2

n∑

i,j=1i<j

cov(Xi, Xj)

= n1

n

(1 − 1

n

)+ 2

n(n − 1)

2

1

n2(n− 1)

= 1.

4.6 LEAST SQUARES ESTIMATION

In many practical contexts, we want to form an estimate of the value of a randomvariable X given the value of a related random variable Y , which may be viewed

Page 255: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.6 Least Squares Estimation 33

as some form of “measurement” of X. For example, X may be the range ofan aircraft and Y may be a noise-corrupted measurement of that range. Inthis section we discuss a popular formulation of the estimation problem, whichis based on finding the estimate c that minimizes the expected value of thesquared error (X − c)2 (hence the name “least squares”).

If the value of Y is not available, we may consider finding an estimate (orprediction) c of X. The estimation error X−c is random (because X is random),but the mean squared error E

[(X − c)2

]is a number that depends on c and can

be minimized over c. With respect to this criterion, it turns out that the bestpossible estimate is c = E[X], as we proceed to verify.

Let m = E[X]. For any estimate c, we have

E[(X − c)2

]= E

[(X −m + m− c)2

]

= E[(X −m)2

]+ 2E

[(X −m)(m− c)

]+ E

[(m− c)2

]

= E[(X −m)2

]+ 2E[X −m](m− c) + (m− c)2

= E[(X −m)2

]+ (m− c)2,

where we used the fact E[X − m] = 0. The first term in the right-hand sideis the variance of X and is unaffected by our choice of c. Therefore, we shouldchoose c in a way that minimizes the second term, which leads to c = m = E[X ](see Fig. 4.10).

cE[X]

Expected SquaredEstimation Error

E [(X- c)2]

var(X)

Figure 4.10: The mean squared error E[(X − c)2], as a function of the estimate

c, is a quadratic in c and is minimized when c = E[X]. The minimum value ofthe mean squared error is var(X).

Suppose now that we observe the experimental value y of some relatedrandom variable Y , before forming an estimate of X. How can we exploit thisadditional information? Once we are told that Y takes a particular value y, thesituation is identical to the one considered earlier, except that we are now in anew “universe,” where everything is conditioned on Y = y. We can thereforeadapt our earlier conclusion and assert that c = E[X | Y = y] minimizes the

Page 256: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

34 Further Topics on Random Variables and Expectations Chap. 4

conditional mean squared error E[(c − X)2 | Y = y

]. Note that the resulting

estimate c depends on the experimental value y of Y (as it should). Thus, wecall E[X | Y = y] the least-squares estimate of X given the experimental value y.

Example 4.27. Let X be uniformly distributed in the interval [4, 10] and supposethat we observe X with some random error W , that is, we observe the experimentalvalue of the random variable

Y = X + W.

We assume that W is uniformly distributed in the interval [−1, 1], and independentof X . What is the least squares estimate of X given the experimental value of Y ?

We have fX(x) = 1/6 for 4 ≤ x ≤ 10, and fX(x) = 0, elsewhere. Conditionedon X being equal to some x, Y is the same as x + W , and is uniform over theinterval [x− 1, x + 1]. Thus, the joint PDF is given by

fX,Y (x, y) = fX(x)fY |X(y |x) =1

6· 1

2=

1

12,

if 4 ≤ x ≤ 10 and x − 1 ≤ y ≤ x + 1, and is zero for all other values of (x, y).The slanted rectangle in the right-hand side of Fig. 4.11 is the set of pairs (x, y) forwhich fX,Y (x, y) is nonzero.

Given an experimental value y of Y , the conditional PDF fX|Y of X is uniformon the corresponding vertical section of the slanted rectangle. The optimal estimateE[X |Y = y] is the midpoint of that section. In the special case of the presentexample, it happens to be a piecewise linear function of y.

x

fX(x )

4 10

1/6

x

4

10

3 5 9 11

Y = X + W where W is a measurement

error that is uniformlydistributed in the interval [-1,1]

y

Least squares estimateE [X | Y = y ]

Figure 4.11: The PDFs in Example 4.27. The least squares estimate of X giventhe experimental value y of the random variable Y = X + W depends on y andis represented by the piecewise linear function shown in the figure on the right.

As Example 4.27 illustrates, the estimate E[X | Y = y] depends on theobserved value y and should be viewed as a function of y; see Fig. 4.12. To

Page 257: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.6 Least Squares Estimation 35

amplify this point, we refer to any function of the available information as anestimator. Given an experimental outcome y of Y , an estimator g(·) (which isa function) produces an estimate g(y) (which is a number). However, if y is leftunspecified, then the estimator results in a random variable g(Y ). The expectedvalue of the squared estimation error associated with an estimator g(Y ) is

E[(

X − g(Y ))2

].

Out of all estimators, it turns out that the mean squared estimation erroris minimized when g(Y ) = E[X |Y ]. To see this, note that if c is any number,we have

E[(

X − E[X | Y = y])2 ∣∣ Y = y

]≤ E

[(X − c)2 | Y = y

].

Consider now an estimator g(Y ). For a given value y of Y , g(y) is a numberand, therefore,

E[(

X −E[X | Y = y])2 | Y = y

]≤ E

[(X − g(y)

)2 ∣∣ Y = y].

This inequality is true for every possible experimental value y of Y . Thus,

E[(

X − E[X |Y ])2 ∣∣ Y

]≤ E

[(X − g(Y )

)2 ∣∣ Y],

which is now an inequality between random variables (functions of Y ). We takeexpectations of both sides, and use the law of iterated expectations, to concludethat

E[(

X − E[X | Y ])2

]≤ E

[(X − g(Y )

)2]

for all functions g(Y ).

E[X |Y = y ]y LEAST SQUARESESTIMATOR

Figure 4.12: The least squares estimator.

Page 258: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

36 Further Topics on Random Variables and Expectations Chap. 4

Key Facts about Least Mean Squares Estimation

• E[(X − c)2

]is minimized when c = E[X]:

E[(

X − E[X])2

]≤ E

[(X − c)2

], for all c.

• E[(X − c)2 |Y = y

]is minimized when c = E[X | Y = y]:

E[(

X − E[X | Y = y])2 ∣∣ Y = y

]≤ E

[(X − c)2 | Y = y

], for all c.

• Out of all estimators g(Y ) of X based on Y , the mean squared esti-

mation error E[(

X − g(Y ))2

]is minimized when g(Y ) = E[X | Y ]:

E[(

X −E[X | Y ])2

]≤ E

[(X − g(Y )

)2], for all functions g(Y ).

Some Properties of the Estimation Error

Let us introduce the notation

X = E[X | Y ], X = X − X,

for the (optimal) estimator and the associated estimation error, respectively.Note that both X and X are random variables, and by the law of iteratedexpectations,

E[X] = E[X − E[X |Y ]

]= E[X ]−E[X] = 0.

The equation E[X] = 0 remains valid even if we condition on Y , because

E[X |Y ] = E[X − X | Y ] = E[X | Y ]− E[X |Y ] = X − X = 0.

We have used here the fact that X is completely determined by Y and thereforeE[X | Y ] = X. For similar reasons,

E[(

X −E[X])X | Y

]=

(X −E[X]

)E[X | Y ] = 0.

Taking expectations and using the law of iterated expectations, we obtain

E[(

X −E[X])X

]= 0.

Page 259: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.6 Least Squares Estimation 37

Note that X = X + X, which yields X − E[X ] = X − E[X] + X. We squareboth sides of the latter equality and take expectations to obtain

var(X) = E[(

X − E[X])2]

= E[(

X − E[X] + X)2

]

= E[(

X − E[X])2

]+ E[X2] + 2E

[(X − E[X]

)X

]

= E[(

X − E[X])2

]+ E[X2]

= var(X) + var(X).

(The last equality holds because E[X] = E[X] and E[X] = 0.) In summary, wehave established the following important formula, which is just another versionof the law of conditional variances introduced in Section 4.3.

var(X) = var(X) + var(X).

Example 4.28. Let us say that the observed random variable Y is uninformative ifthe mean squared estimation error E[X2] = var(X) is the same as the unconditionalvariance var(X) of X. When is this the case?

Using the formula

var(X) = var(X) + var(X),

we see that Y is uninformative if and only if var(X

)= 0. The variance of a random

variable is zero if and only if that random variable is a constant, equal to its mean.We conclude that Y is uninformative if and only if X = E[X |Y ] = E[X], for everyrealization of Y .

If X and Y are independent, we have E[X |Y ] = E[X] and Y is indeeduninformative, which is quite intuitive. The converse, however, is not true. Thatis, it is possible for E[X | Y ] to be always equal to the constant E[X], without Xand Y being independent. (Can you construct an example?)

Estimation Based on Several Measurements

So far, we have discussed the case where we estimate one random variable Xon the basis of another random variable Y . In practice, one often has accessto the experimental values of several random variables Y1, . . . , Yn, that can beused to estimate X . Generalizing our earlier discussion, and using essentially

Page 260: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

38 Further Topics on Random Variables and Expectations Chap. 4

the same argument, the mean squared estimation error is minimized if we useE[X | Y1, . . . , Yn] as our estimator. That is,

E[(

X − E[X |Y1, . . . , Yn])2

]≤ E

[(X − g(Y1, . . . , Yn)

)2],

for all functions g(Y1, . . . , Yn).

This provides a complete solution to the general problem of least squaresestimation, but is sometimes difficult to implement, because:

(a) In order to compute the conditional expectation E[X | Y1, . . . , Yn], we needa complete probabilistic model, that is, the joint PDF fX,Y1,...,Yn(·) of n+1random variables.

(b) Even if this joint PDF is available, E[X | Y1, . . . , Yn] can be a very compli-cated function of Y1, . . . , Yn.

As a consequence, practitioners often resort to approximations of the conditionalexpectation or focus on estimators that are not optimal but are simple and easyto implement. The most common approach involves linear estimators, of theform

a1Y1 + · · ·+ anYn + b.

Given a particular choice of a1, . . . , an, b, the corresponding mean squared erroris

E[(X − a1Y1 − · · · − anYn − b)2

],

and it is meaningful to choose the coefficients a1, . . . , an, b in a way that min-imizes the above expression. This problem is relatively easy to solve and onlyrequires knowledge of the means, variances, and covariances of the different ran-dom variables. We develop the solution for the case where n = 1.

Linear Least Mean Squares Estimation Based on a Single Measurement

We are interested in finding a and b that minimize the mean squared estimationerror E

[(X−aY −b)2

], associated with a linear estimator aY +b of X. Suppose

that a has already been chosen. How should we choose b? This is the same ashaving to choose a constant b to estimate the random variable aX − Y and, byour earlier results, the best choice is to let b = E[X − aY ] = E[X]− aE[Y ].

It now remains to minimize, with respect to a, the expression

E[(

X − aY − E[X] + aE[Y ])2

],

which is the same as

E[(

(X − E[X])− a(Y −E[Y ]))2

]

= E[(X − E[X])2

]+ a2E

[(Y − E[Y ])2

]− 2aE

[(X − E[X]

)(Y −E[Y ]

)]

= σ2X + a2σ2

Y − 2a · cov(X, Y ),

Page 261: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 39

where cov(X,Y ) is the covariance of X and Y :

cov(X,Y ) = E[(X − E[X])(Y − E[Y ])

].

This is a quadratic function of a, which is minimized at the point where itsderivative is zero, that is, if

a =cov(X, Y )

σ2Y

=ρσXσY

σ2Y

= ρσX

σY,

where

ρ =cov(X, Y )

σXσY

is the correlation coefficient. With this choice of a, the mean squared estimationerror is given by

σ2X + a2σ2

Y − 2a · cov(X,Y ) =σ2X + ρ2

σ2X

σ2Y

σ2Y − 2ρ

σX

σyρσXσY

=(1− ρ2)σ2X .

Linear Least Mean Squares Estimation Formulas

The least mean squares linear estimator of X based on Y is

E[X ] +cov(X,Y )

σ2Y

(Y − E[Y ]

).

The resulting mean squared estimation error is equal to

(1− ρ2)var(X).

4.7 THE BIVARIATE NORMAL DISTRIBUTION

We say that two random variables X and Y have a bivariate normal distributionif there are two independent normal random variables U and V and some scalarsa, b, c, d, such that

X = aU + bV, Y = cU + dV.

Page 262: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

40 Further Topics on Random Variables and Expectations Chap. 4

To keep the discussion simple, we restrict ourselves to the case where U , V (andtherefore, X and Y as well) have zero mean.

A most important property of the bivariate normal distribution is the fol-lowing:

If two random variables X and Y have a bivariate normal distribution andare uncorrelated, then they are independent.

This property can be verified using multivariate transforms. We assumethat X and Y have a bivariate normal distribution and are uncorrelated. Recallthat if z is a zero-mean normal random variable with variance σ2

Z , then E[eZ ] =MZ(1) = σ2

Z/2. Fix some scalars s1, s2 and let Z = s1X + s2Y . Then, Z is thesum of the independent normal random variables (as1 +cs2)U and (bs1 +ds2)V ,and is therefore normal. Since X and Y are uncorrelated, the variance of Z iss21σ

2X + s2

2σ2Y . Then,

MX,Y (s1, s2) = E [es1X+s2Y ]

= E[eZ ]

= e(s21σ2

X+s22σ2

Y )/2.

Let X and Y be independent zero-mean normal random variables with the samevariances σ2

X and σ2Y as X and Y . Since they are independent, they are uncor-

related, and the same argument as above yields

MX,Y (s1, s2) = e(s21σ2

X+s22σ2

Y )/2..

Thus, the two pairs of random variables (X, Y ) and (X,Y ) are associated withthe same multivariate transform. Since the multivariate transform completelydetermines the joint PDF, it follows that the pair (X, Y ) has the same jointPDF as the pair (X, Y ). Since X and Y are independent, X and Y must alsobe independent.

Let us define

X =E[XY ]

E[Y 2]Y, X = X − X.

Thus, X is the best linear estimator of X given Y , and X is the estimation error.Since X and Y are linear combinations of independent normal random variablesU and V , it follows that Y and X are also linear combinations of U and V . Inparticular, Y and X have a bivariate normal distribution. Furthermore,

cov(Y, X) = E[Y X ] = E[Y X]− E[Y X] = E[Y X]− E[XY ]

E[Y 2]E[Y 2] = 0.

Page 263: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 41

Thus, Y and X are uncorrelated and, therefore, independent. Since X is a scalarmultiple of Y , we also see that X and X are independent.

We now start from the identity

X = X + X,

which implies that

E[X |Y ] = E[X |Y ] + E[X | Y ].

But E[X | Y ] = X because X is completely determined by Y . Also, X is inde-pendent of Y and

E[X | Y ] = E[X] = E[X − X] = 0.

(The last equality was obtained because X and Y are assumed to have zero meanand X is a constant multiple of Y .) Putting everything together, we come tothe important conclusion that the best linear estimator X is of the form

X = E[X | Y ].

Differently said, the optimal estimator E[X | Y ] turns out to be linear.Let us now determine the conditional density of X, conditioned on Y . We

have X = X + X. After conditioning on Y , the value of the random variableX is completely determined. On the other hand, X is independent of Y and itsdistribution is not affected by conditioning. Therefore, the conditional distribu-tion of X given Y is the same as the distribution of X, shifted by X. Since X isnormal with mean zero and some variance σ2

X, we conclude that the conditional

distribution of X is also normal with mean X and variance σ2X

.We summarize our conclusions below. Although our discussion used the

zero-mean assumption, these conclusions also hold for the non-zero mean caseand we state them with this added generality.

Properties of the Bivariate Normal Distribution

Let X and Y have a bivariate normal distribution. Then:

• X and Y are independent if and only if they are uncorrelated.

• The conditional expectation is given by

E[X | Y ] = E[X] +cov(X, Y )

σ2Y

(Y −E[Y ]).

It is a linear function of Y and has a normal distribution.

Page 264: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

42 Further Topics on Random Variables and Expectations Chap. 4

• The conditional distribution of X given Y is normal with mean E[X | Y ]and variance

σ2X

= (1− ρ2)σ2X .

Finally, let us note that while if X and Y have a bivariate normal distri-bution, then X and Y are (individually) normal random variables, the reverseis not true even if X and Y are uncorrelated. This is illustrated in the followingexample.

Example 4.29. Let X have a normal distribution with zero mean and unitvariance. Let z be independent of X, with P(Z = 1) = P(Z = −1) = 1/2. LetY = ZX, which is also normal with zero mean (why?). Furthermore,

E[XY ] = E[ZX2] = E[Z]E[X2] = 0× 1 = 0,

so X and Y are uncorrelated. On the other hand X and Y are clearly dependent.(For example, if X = 1, then Y must be either−1 or 1.) This may seem to contradictour earlier conclusion that zero correlation implies independence? However, in thisexample, the joint PDF of X and Y is not multivariable normal, even though bothmarginal distributions are normal.

Page 265: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 43

S O L V E D P R O B L E M S

SECTION 4.1. Transforms

Problem 1. Let X be a random variable that takes the values 1, 2, and 3 with thefollowing probabilities:

P(X = 1) =1

2, P(X = 2) =

1

4, P(X = 3) =

1

4.

Find the transform of X and use it to obtain the first three moments, E[X], E[X2],E[X3].

Solution. The transform is given by

M (s) = E[esX ] =1

2es +

1

4e2s +

1

4e3s.

We have

E[X] =d

dsM (s)

∣∣∣s=0

=1

2+

2

4+

3

4=

7

4,

E[X2] =d2

ds2M(s)

∣∣∣s=0

=1

2+

4

4+

27

4=

15

4,

E[X3] =

d3

ds3M(s)

∣∣∣s=0

=1

2+

8

4+

27

4=

37

4.

Problem 2. A nonnegative integer-valued random variable X has one of thefollowing two expressions as its transform:

1. M(s) = e2(ees−1−1).

2. M(s) = e2(ees−1).

(a) Explain why one of the two cannot possibly be the transform, and indicate whichone is the true transform.

(b) Find P(X = 0).

Solution. (a) By the definition of the transform,

M(s) = P(X = 0) + esP(X = 1) + e2sP(X = 2) + · · ·

so when evaluated at s = 0, the transform should equal 1. Only the first option satisfiesthis requirement.

(b) By the above expansion, we see that if we take the limit of the transform as s → −∞,we obtain P(X = 0). Thus

P(X = 0) = lims→−∞

M(s) = e2(e−1−1) ≈ 0.2825.

Page 266: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

44 Further Topics on Random Variables and Expectations Chap. 4

Problem 3. Find the PDF of the continuous random variable X that has thetransform

M(s) =1

3· 2

2 − s+

2

3· 3

3 − s.

Solution. We recognize this transform as corresponding to the following mixture ofexponential PDFs:

fX(x) =

13 · 2e−2x + 2

3 · 3e−3x for x ≥ 0,0 otherwise.

By the inversion theorem, this must be the desired PDF.

Problem 4. Let X be a random variable that takes nonnegative integer values, andhas a transform of the form

MX(s) = K14 + 5es − 3e2s

8(2 − es),

where K is some scalar. Find E[X], pX(1), and E[X |X 6= 0].

Solution. We find K by using the equation MX(0) = 1:

K =

(8(2 − es)

14 + 5es − 3e2s

) ∣∣∣s=0

=8

16=

1

2.

We have

E[X] =dMX(s)

ds

∣∣∣s=0

=K

8

((5es − 6e2s)(2− es)−1 + (−1)(−1)es(2− es)−2(14 + 5es − 3e2s)

)∣∣∣s=0

=K

8

((−1)(+1) + (1)(14 + 5 − 3)

)

=15K

8

=15(1/2)

8

=15

16.

Since X takes nonnegative integer values, we have

MX(s) = pX(0) · e0 + pX(1) · es + pX(2) · e2s + pX(3) · e3s + · · ·

dMX(s)

ds= pX(1) · es + 2pX(2) · e2s + 3pX(3) · e3s + · · ·

dMX(s)

ds· 1

es= pX(1) + 2pX(2) · es

+ 3pX(3) · e2s+ · · ·

Page 267: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 45

Setting es = 0 eliminates all but the first term on the right hand side, so we have

pX(1) =

(dMX(s)

ds· 1

es

)∣∣∣∣∣es=0

=1

16

((5− 6es)(2 − es)−1 + (−1)(−1)(2 − es)−2(14 + 5es − 3e2s)

)∣∣∣es=0

=3

8.

Let A = X 6= 0. We have

pX |A(x |A) =

pX(x)

P(A) if x ∈ A,0 otherwise,

so that

E[X |X 6= 0] =

∞∑

x=1

x · pX |A(x |A)

=

∞∑

x=1

x · pX(x)

P(A)

=E[X]

P(A)

=15/16

P(A).

We haveP(A) = 1 −PX = 0

= 1 −MX(s)

∣∣∣es=0

= 1 −(

14

16

)(1

2

)

= 1 − 7

16

=9

16.

Therefore,

E[X |X 6= 0] =15/16

9/16=

5

3.

Problem 5. Let X, Y , and Z be independent random variables. X is Bernoulli withparameter 1/3. Y is exponential with parameter 2. Z is Poisson with parameter 3.

(a) Consider the new random variable U = XY + (1 − X)Z. Find the transformassociated with U .

(b) Find the transform of 2Z + 3.

(c) Find the transform of Y + Z.

Page 268: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

46 Further Topics on Random Variables and Expectations Chap. 4

Solution. (a) We have U = X if X = 1, which happens with probability 1/3, andU = Z if X = 0, which happens with probability 2/3. Therefore, U is mixture ofrandom variables and its transform is

MU(s) = P(X = 1)MY (s) + P(X = 0)MZ(s) =1

3

2

2 − s+

2

3e3(es−1).

(b) Let V = 2Z + 3. We have

MV (s) = e3sMZ(2s) = e3se3(e2s−1) = e3(s−1+e2s).

(c) Let W = Y + Z. We have

MW (s) = MY (s)MZ(s) =2

2 − se3(es−1).

Problem 6. * Let X be a discrete random variable taking nonnegative integer values.Let M(s) be the transform of X.

(a) Show thatP(X = 0) = lim

s→−∞M(s).

(b) Use part (a) to verify that if X is a binomial random variable with parametersn and p, we have P(X = 0) = (1− p)n. Furthermore, if X is a Poisson randomvariable with parameter λ, we have P(X = 0) = e−λ.

(c) Suppose that X is instead known to take only integer values that are greater orequal to a given integer k. How can we calculate P (X = k) using the transformof X?

Solution. (a) We have

M (s) =

∞∑

k=0

P(X = k)eks

.

As s → −∞, all the terms eks with k > 0 tend to 0, so we obtain lims→−∞M (s) =P(X = 0).

(b) In the case of the binomial, we have from the transform tables

M (s) = (1− p + pes)n,

so that lims→−∞ M(s) = (1− p)n. In the case of the Poisson, we have

M (s) = eλ(es−1),

so that lims→−∞ M(s) = e−λ.

(c) The random variable Y = X − k takes only nonnegative integer values and has

transform MY (s) = e−skM (s) (cf. Example 4.4). Since P(Y = 0) = P(X = k), wehave from part (a)

P(X = k) = lims→−∞

e−sk

M (s).

Page 269: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 47

Problem 7. * Transform of the discrete uniform. Find the transform of theinteger-valued random variable X that is uniformly distributed in the range [M,M+N ].

Solution. The PMF of X is

pX(k) =

1N+1 if k = M,M + 1, . . . , M + N ,0 otherwise.

The transform is

M (s) =

∞∑

k=−∞

esk

P(X = k)

=

M+N∑

k=M

1

N + 1esk

=esM

N + 1

N∑

k=0

esk

=esM

N + 1· 1− es(N+1)

1− es.

Problem 8. * Transform of the continuous uniform. Let X be a continuousrandom variable that is uniformly distributed between a and b.

(a) Find the transform of X.

(b) Use the transform in (a) to find the mean and the variance of X.

Solution. (a) The transform is given by

M(s) = E[esX ] =

∫ b

a

esx

b− adx =

esb − esa

s(b− a).

(b) We have

E[Xn] =dn

dsnM (s)

∣∣∣s=0

.

Thus for n = 1 we have using L’ Hopital’s rule

E[X ] =d

dsM(s)

∣∣∣s=0

=

(1

b− a

)esb − esa

s2+

(1

b− a

)besb − aesa

s

∣∣∣∣∣s=0

= − b2 − a2

2(b− a)+

b2 − a2

b− a

=b + a

2.

Page 270: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

48 Further Topics on Random Variables and Expectations Chap. 4

To find var(X), we calculate E[X2] using the second derivative of the transform. Wehave using L’ Hopital’s rule

E[X2] =

d2

ds2M(s)

∣∣∣s=0

=

(2

b− a

)esb − esa

s3−

(2

b− a

)besb − aesa

s2+

(1

b− a

)b2esb − a2esa

s

∣∣∣∣∣s=0

=1

3

b3 − a3

b− a+

a3 − b3

b− a+

b3 − a3

b− a

=1

3(b

2+ ab + a

2).

Therefore

var(X) = E[X2] −

(E[X]

)2=

1

3(b

2+ ab + a

2)−

(b + a

2

)2

.

Problem 9. * Mean and variance of the Poisson. Use the formula for thetransform of a Poisson random variable X to calculate E[X] and E[X2].

Solution. Let λ be the parameter of the Poisson random variable X. Its transform isgiven by

MX(s) = eλ(es−1), s < λ.

Using the equation

dn

dsnM (s)

∣∣∣∣s=0

= E[Xn],

we obtain

E[X] = (λeseλ(es−1))

∣∣∣∣s=0

= λ · 1 · eλ(1−1) = λ,

E[X2] =(λ(eseλ(es−1) + es · λes · eλ(es−1))

) ∣∣∣∣s=0

= λ + λ2.

Problem 10. * Find the third, fourth, and fifth moments of the exponential randomvariable with parameter λ.

Solution. The transform is

M (s) =λ

λ− s.

Thus,

d

dsM(s) =

λ

(λ− s)2,

d2

ds2M(s) =

(λ − s)3,

d3

ds3M (s) =

(λ− s)4,

d4

ds4M (s) =

24λ

(λ− s)5,

d5

ds5M(s) =

120λ

(λ − s)6.

Page 271: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 49

By setting s = 0, we obtain

E[X3] =6

λ3, E[X4] =

24

λ4, E[X5] =

120

λ5.

Problem 11. * Using partial fraction expansions. Suppose that the transformof the random variable X has the form

M (s) =A(es)

B(es),

where A(t) and B(t) are polynomials of the generic variable t. Assume that A(t) andB(t) have no common roots and the degree of A(t) is smaller than the degree of B(t).Assume also that B(t) has distinct, real, and nonzero roots. Then it can be seen thatM(s) can be written in the form

M (s) =a1

1 − r1es+ · · ·+ am

1 − rmes,

where 1/r1, . . . , 1/rm are the roots of B(t) and the ai are constants that are equal tolim

es→ 1ri

(1− ries)M(s), i = 1, . . . ,m.

(a) Show that the PMF of X has the form

P(X = k) =∑m

i=1air

ki if k = 0, 1, . . .,

0 otherwise.

Note: For large k, the PMF of X can be approximated by airki, where i is the

index corresponding to the largest |ri| (assuming i is unique).

(b) Extend the result of part (a) to the case where M (s) = ebsA(t)/B(t) and b is aninteger.

Solution. (a) We have for all s such that |ri|es < 1

1

1 − ries= 1 + rie

s + r2i e2s + · · ·

Therefore

M(s) =

m∑

i=1

ai +

(m∑

i=1

airi

)es +

(m∑

i=1

air2i

)e2s + · · ·

and by inverting this transform, we see that

P(X = k) =

m∑

i=1

airki

for k ≥ 0 and P(X = k) = 0 for k < 0.

Page 272: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

50 Further Topics on Random Variables and Expectations Chap. 4

(b) In this case M(s) corresponds to the translation by b of the random variable whosetransform is A(t)/B(t) (cf. Example 4.4), so we have

P(X = k) =

∑m

i=1air

(k−b)i if k = b, b + 1, . . .,

0 otherwise.

SECTION 4.2. Sums of Independent Random Variables - Convolu-tions

Problem 12. A soccer team has three designated players who take turns strikingpenalty shots. The probability of success of the ith player is a given pi, independently ofthe success of the other players. Let X be the number of successful penalty shots aftereach player has had one turn. Use convolution to calculate the PMF of X. Confirmyour answer by first calculating the transform of X and then obtaining the PMF fromthe transform.

Solution. Let Xi, i = 1, 2, 3, be the Bernoulli random variable that take the value 1 ifthe ith player is successful. We have X = X1 + X2 + X3. Let qi = 1− pi. Convolutionof X1 and X2 yields the PMF of W = X1 + X2:

pW (w) =

q1q2 if w = 0,q1p2 + p1q2 if w = 1,p1p2 if w = 2,0 otherwise.

Convolution of W and X3 yields the PMF of X = X1 + X2 + X3:

pX(x) =

q1q2q3 if w = 0,p1q2q3 + q1p2q3 + q1q2p3 if w = 1,q1p2p3 + p1q2p3 + p1p2q3 if w = 2,p1p2p3 if w = 3,0 otherwise.

The transform of X is the product of the transforms of Xi, i = 1, 2, 3. We have

MX(s) = (q1 + p1es)(q2 + p2e

s)(q3 + p3es).

By carrying out the multiplications above, and by examining the coefficients of theterms eks, we obtain the probabilities P(X = k). These probabilities are seen tocoincide with the ones computed by convolution.

Problem 13. Harry and Larry approach each other from very far away. Harry willsee Larry at a distance that is exponentially distributed with parameter 1 km, whileLarry will see Harry at a distance that is uniformly distributed between 0 and 1 km.Use convolution to find the PDF of X, the distance during which only one of the twopersons will be seeing the other.

Solution. Let Y and Z be the distances at which Harry will first see Larry, and Larrywill first see Harry, respectively. We have X = |W |, where W = Y − Z. We find the

Page 273: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 51

PDF of W by convolution of the exponential with parameter 1 with the uniform in theinterval [−1, 0]. Then we note that

fX(x) =

fW (x) + fW (−x) if x ≥ 0,0 otherwise.

Problem 14. The random variables X, Y , and Z are independent and uniformlydistributed between zero and one. Find the PDF of W = X + Y + Z.

Solution. Let V = X + Y . As in Example 4.14, the PDF of V is

fV (v) =

v 0 ≤ v ≤ 1,2 − v 1 ≤ v ≤ 2,0 otherwise.

We have W = V + Z. By convolution of the PDFs fV and fZ , we obtain

fW (w) =

w2/2 0 ≤ w ≤ 1,1− (w − 1)2/2 − (2− w)2/2 1 ≤ w ≤ 2,(3− w)2/2 2 ≤ w ≤ 3,0 otherwise.

Problem 15. Consider a PDF that is positive only within an interval [a, b] and issymmetric around the mean (a + b)/2. Let X and Y be independent random variablesthat both have this PDF. Suppose that you have calculated the PDF and the transformof X + Y . How can you easily obtain the PDF and the transform of X − Y ?

Solution. We have X − Y = X + Z − (a + b), where Z = a + b − Y is distributedidentically with X and Y .

SECTION 4.3. Conditional Expectation as a Random Variable

Problem 16. Oscar is an engineer who is equally likely to work between zero andone hundred hours each week (i.e., the time he works is uniformly distributed betweenzero and one hundred). He gets paid one dollar an hour. If Oscar works more thanfifty hours during a week, there is a probability of 1/2 that he will actually be paidovertime, which means he will receive two dollars an hour for each hour he works longerthan fifty hours. Otherwise, he will just get his normal pay for all of his hours thatweek. Independently of receiving overtime pay, if Oscar works more than seventy fivehours in a week, there is a probability of 1/2 that he will receive a one hundred dollarbonus, in addition to whatever else he earns. Find the expected value and variance ofOscar’s weekly salary.

Solution. Let W be the number of hours Oscar works in a week, and T be the totalamount of Oscar’s earnings in a week (including overtime and bonus). Let also O bethe event that Oscar receives overtime pay, and B be the event that Oscar receives abonus. We will find E[T ] and var(T ) by using iterated expectations.

We have

E[T ] =

7∑

i=1

P(Ai)E[T |Ai]

Page 274: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

52 Further Topics on Random Variables and Expectations Chap. 4

where A1, . . . , A7 are the events

A1 = 0 ≤ w ≤ 50,A2 = 50 < w ≤ 75 ∩ O

′,

A3 = 50 < w ≤ 75 ∩ O,

A4 = 75 < w ≤ 100 ∩ O′ ∩ B,

A5 = 75 < w ≤ 100 ∩ O′ ∩ B′,

A6 = 75 < w ≤ 100 ∩ O ∩ B,

A7 = 75 < w ≤ 100 ∩ O ∩ B′.

Note that A1, A2, ..., A7 form a partition of the sample space.Over each Ai, the conditional PDF fT |Ai

(t |Ai) is constant because any lin-ear function aX + b of a uniformly distributed RV X is also uniformly distributed.Therefore,

fT |A1(t |A1) =

1

50for 0 ≤ t ≤ 50,

fT |A2(t |A2) =

1

25for 50 < t ≤ 75,

fT |A3(t |A3) =

1

50for 50 < t ≤ 100,

fT |A4(t |A4) =

1

25for 175 < t ≤ 200,

fT |A5(t |A5) =1

25for 75 < t ≤ 100,

fT |A6(t |A6) =

1

50for 200 < t ≤ 250,

fT |A7(t |A7) =1

50for 100 < t ≤ 150.

andE[T |A1] = 25,

E[T |A2] =125

2,

E[T |A3] = 75,

E[T |A4] =375

2,

E[T |A5] =175

2,

E[T |A6] = 225,

E[T |A7] = 125.

The expected salary per week is then equal to

E[T ] =1

2· 25 +

1

8· 125

2+

1

8· 75 +

1

16· 375

2+

1

16· 175

2+

1

16· 225 +

1

16· 125 = 68.75.

We use a similar argument to find E[T 2]. We have

E[T 2] =

7∑

i=1

P(Ai)E[T 2 |Ai].

Page 275: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 53

Using the fact that E[X2] = (a2 + ab + b2)/3 = ((a + b)2 − ab)/3 for any uniformlydistributed RV X ranging from a to b, we obtain

E[T 2 |A1] = 502/3,

E[T 2 |A2] = (1252 − 50 · 75)/3,

E[T2 |A3] = (150

2 − 50 · 100)/3,

E[T 2 |A4] = (3752 − 175 · 200)/3,

E[T 2 |A5] = (1752 − 75 · 100)/3,

E[T 2 |A6] = (4502 − 200 · 250)/3,

E[T2 |A7] = (250

2 − 100 · 150)/3.

Therefore,

E[T 2] =1

2· 2500

3+

1

8· 11875

3+

1

8· 17500

3+

1

16· 105625

3

+1

16· 23125

3+

1

16· 152500

3+

1

16· 47500

3

=101875

12.

and

var(T ) = E[T 2] − (E[T ])2 =180625

48≈ 3763.

Problem 17. Pat and Nat are dating, and all of their dates are scheduled to startat 9pm. Nat always arrives promptly at 9pm. Pat is highly disorganized and arrivesat a time that is uniformly distributed between 8pm and 10pm. Let X be the time inhours between 8pm and the time when Pat arrives. If Pat arrives after 9pm, their datewill last exactly 3 hours. If Pat arrives after 9pm, their date will last for a time thatis uniformly distributed between 0 and 3−X hours. The date starts at the time theymeet. Nat gets irritated when Pat is late and will the relationship after the seconddate on which Pat is late by more than 45 minutes. All dates are independent of anyother dates.

(a) What is the expected number of hours Pat waits for Nat to arrive? (Note: Thewaiting time must be nonnegative.)

(b) What is the expected duration of any particular date?

(c) What is the expected number of dates they will have before breaking up?

Solution. (a) Let W be the number of hours that Pat waits. We have

E[X] = P(0 ≤ X ≤ 1)E[W | 0 ≤ X ≤ 1] + P(X > 1)E[W |X > 1].

Since W > 0 only if X > 1, we have

E[W ] = P(X > 1)E[W |X > 1] =1

2· 1

2=

1

4.

Page 276: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

54 Further Topics on Random Variables and Expectations Chap. 4

(b) Let D be the duration of a date. We have E[D | 0 ≤ X ≤ 1] = 3 and by usingiterated expectations,

E[D |X > 1] = E[E[D |X, X > 1] |X > 1

]= E

[3 −X

2|X > 1

].

HenceE[D] = P(0 ≤ X ≤ 1)E[D | 0 ≤ X ≤ 1] + P(X > 1)E[D |X > 1]

=1

2· 3 +

1

2· E

[3 −X

2|X > 1

]

=3

2+

1

2

(3

2− E[X |X > 1]

2

)

=3

2+

1

2

(3

4− 3/2

2

)

=15

8.

(c) The probability that Pat will be late by more than 45 minutes is 1/8. The number ofdates before breaking up is the sum of two geometrically distributed random variableswith parameter 1/, and its expected value is 2 · 8 = 16.

Problem 18. A retired professor comes to his office at any time between 9 AM and1 PM, with all times in that interval being equally likely, and performs a single task.The duration of the task is exponentially distributed with parameter λ(y) = 1/(5− y),where y is the length of the time interval between 9 AM and the time of his arrival.

(a) What is the expected time that the professor devotes to his task?

(b) What is the expected time that the professor leaves his office?

(c) The professor has a PhD student who on a given day comes to see him at a timethat is uniformly distributed between 9 AM and 5 PM. If the student does notfind the professor, he leaves and does not return. If he finds the professor, hespends an amount of time that is uniformly distributed between 0 and 1 hour.The professor will spend the same amount of total time on his task regardless ofwhether he is interrupted by the student. What is the expected amount of timethat the professor will spend with the student and what is the expected time thathe will leave his office?

Solution. (a) Consider the following two random variables:

X = amount of time the professor devotes to his task [exponentially distributed withparameter λ = 1/(5− y)]

Y = length of time between 9 AM and his arrival (uniformly distributed between 0and 4)

Since the random variable X depends on the value y of Y , we have

E[X ] = E[E[X |Y ]

]=

∫ ∞

−∞E[X |Y = y]fY (y)dy.

We have

E[X | Y = y] =1

λ= 5− y.

Page 277: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 55

Also, the PDF for the random variable Y is

fY (y) =

1/4 if 0 ≤ y ≤ 4,0 otherwise.

Therefore,

E[X ] =

∫ 4

0

1

4(5− y)dy = 3 hours.

(b) Let Z be the length of time from 9 AM until the professor leaves his office. Then

Z = X + Y.

So,

E[Z] = E[X] + E[Y ].

We already know E[X ] from part (a). Since the random variable Y is uniformly dis-tributed between 0 and 4, E[Y ] = 2. Therefore,

E[Z] = 3 + 2 = 5.

Thus the expected time that the professor leaves his office is 5 hours after 9 AM.

(c) We define the following random variables:

W = length of time between 9 AM and arrival of the PhD student (uniformly dis-tributed between 9 AM and 5 PM).

R = amount of time the student will spend with the professor, if he finds the professor(uniformly distributed between 0 and 1 hour).

T = amount of time the professor will spend with the student.

Let also F be the event that the student finds the professor.To find E[T ], we write

E[T ] = P(F )E[T |F ] + P(F′)E[T |F ′]

Using the problem data,

E[T |F ] = E[R] =1

2

(this is the expected value of a uniformly distribution ranging from 0 to 1),

E[T |F ′] = 0

(since the student leaves if he does not find the professor). We have

E[T ] = E[T |F ]P(F ) =1

2P(F ),

so we need to find P(F ).

Page 278: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

56 Further Topics on Random Variables and Expectations Chap. 4

In order that the student finds the professor, his arrival should be between thearrival and the departure of the professor. Thus

P(F ) = P(Y ≤ W ≤ X + Y ).

We have that W can be between 0 (9AM) and 8 (5PM), but X + Y can be any valuegreater than 0. In particular, it may happen that the sum is greater than the upperbound for W . We write

P(F ) = P(Y ≤ W ≤ X + Y ) = 1 −(P(W < Y ) + P(W > X + Y )

)

We have

P(W < Y ) =

∫ y=4

y=0

1

4

∫ w=y

w=0

1

8dw dy =

1

4

and

P(W > X + Y ) =

∫ y=4

y=0

P(W > X + Y |Y = y) · fY (y)dy

=

∫ y=4

y=0

P(X < W − Y |Y = y) · fY (y)dy

=

∫ y=4

y=0

∫ w=8

w=y

FX | Y (w − y) · fW (w) · fY (y)dw dy

=

∫ y=4

y=0

1

4

∫ w=8

w=y

1

8

∫ x=w−y

x=0

1

5 − ye−x/5−ydx dw dy

=12

32+

1

32

∫ y=4

y=0

(5− y)e− 8−y

5−y dy.

Integrating numerically, we have

∫ y=4

y=0

(5− y)e− 8−y

5−y dy = 1.7584.

Thus,

P(Y ≤W ≤ X + Y ) = 1 − (P(W < Y ) + P(W > X + Y )) = 1 − 0.68 = 0.32.

The expected amount of time the professor will spend with the student is then

E[T ] =1

2P(F ) =

1

20.32 = 0.16 = 9.6 mins.

Next, we want to find the expected time the professor will leave his office. LetZ be the length of time measured from 9AM until he leaves his office. If the professordoesn’t spend any time with the student, then Z will be equal to X + Y . On the otherhand, if the professor is interrupted by the student, then the length of time will beequal to X + Y + R. This is because the professor will spend the same amount of totaltime on the task regardless of whether he is interrupted by the student. Therefore,

E[Z] = P(F ′)E[Z |F ′] + P(F )E[Z |F ] = P(F ′)E[X + Y ] + P(F )E[X + Y + R].

Page 279: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 57

Using the results of the earlier calculations,

E[X + Y ] = 5,

E[X + Y + R] = E[X + Y ] + E[R] = 5 +1

2=

11

2.

Therefore,

E[Z] = 0.68 · 5 + 0.32 · 11

2= 5.16.

Thus the expected time the professor will leave his office is 5.16 hours after 9 AM.

Problem 19. Consider a gambler who at each gamble either wins or loses his betwith probabilities p and 1− p. When p > 1

2 , a popular gambling system, known as theKelley strategy, is to always bet the fraction 2p− 1 of the current fortune. Assumingp > 1/2, compute the expected fortune after n gambles of a gambler who starts withx units and employs the Kelley strategy.

Solution. The problem is simplified by looking at the fraction of the original stake thatthe gambler has at any given moment. Because the expected value operation is linear,we can compute the expected fraction of the original stake and multiply by the originalstake to get the expected total fortune (the original stake is a constant).

If the gambler has a at the beginning of a round, he bets a(2p− 1) on the round.If he wins, he will have a +a(2p− 1) units. If he loses, he will have a− a(2p−1) units.Thus at the end of the round, he will have 2pa following a win, and 2(1− p)a followinga loss.

Thus, we see that winning multiplies the gambler’s fortune by 2p and losingmultiplies it by 2(1− p). Therefore, if he wins k times and loses m times, he will have(2p)k

(2(1 − p)

)mtimes his original fortune. We can also compute the probability of

this event. Let Y be the number of times the gambler wins in the first n gambles. ThenY has the binomial PMF:

pY (y) =

(n

y

)p

y(1− p)

n−y, y = 0, 1, . . . , n.

We can now calculate the expected fraction of the original stake that he has aftern gambles. Let Z be a random variable representing this fraction. We know that Z isrelated to Y via

Z = (2p)Y(2(1− p)

)n−Y.

Page 280: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

58 Further Topics on Random Variables and Expectations Chap. 4

We will calculate the expected value of Z using the density of Y .

E[Z] =

n∑

y=0

Z(y)pY (y)

=

n∑

y=0

(2p)y[2(1 − p)]n−y

(n

y

)py(1− p)n−y

=

n∑

y=0

2ypy2n−y(1− p)n−y

(n

y

)py(1− p)n−y

= 2n

n∑

y=0

py(1− p)n−y

(n

y

)py(1− p)n−y

= 2n

n∑

y=0

(n

y

) (p2

)y [(1− p)2

]n−y

= 2n(p2 + (1− p)2

)n,

where the last equality follows using the generalized binomial formula

n∑

k=0

(n

k

)akbn−k = (a + b)n.

Thus the gambler’s expected fortune is

2n(p2 + (1− p)2

)nx,

where x is the fortune at the beginning of the first round.An alternative method for solving the problem involves using iterated expecta-

tions. Let Xk be the fortune after the kth gamble. Again, we use the fact that theexpected fortune after the kth gamble is

Xk = 2(p2 + (1− p)2

)Xk−1.

Therefore, using iterated expectations, the fortune after n gambles is

E[Xn] = E [E[Xn |Xn−1]] = 2(p2 + (1− p)2

)E[Xn−1]

= 2(p2 + (1− p)2

)E [E[Xn−1 |Xn−2]] =

(2(p2 + (1− p)2

))2E[Xn−2]

=(2(p2 + (1− p)2

))2E [E[Xn−2 |Xn−3]] =

(2(p2 + (1− p)2

))3E[Xn−3]

· · ·=

(2n

(p2 + (1− p)2

))nE[X] = 2n

(p2 + (1− p)2

)nx.

Problem 20. Let X and Y be two random variables that are uniformly distributedover the triangle formed by the points (0, 0), (1, 0), and (0, 2) (this is an asymmetric

Page 281: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 59

version of the PDF of Example 4.15). Calculate E[X] and E[Y ] using the law of iteratedexpectations and a method similar to the one of Example 4.15.

Solution. The conditional density of X given that Y = y is uniform over the interval[0, (2− y)/2] and we have

E[X | Y = y] =2 − y

4, 0 ≤ y ≤ 2.

Therefore, using the law of iterated expectations,

E[X] = E[E[X | Y ]

]= E

[2 − Y

4

]=

2 − E[Y ]

4.

Similarly, the conditional density of Y given that X = x is uniform over theinterval [0, 2(1 − x)] and we have

E[Y |X = x] = 1 − x, 0 ≤ x ≤ 1.

ThereforeE[Y ] = E

[E[Y |X]

]= E[1−X] = 1 − E[X].

By solving the two equations above for E[X] and E[Y ], we obtain

E[X ] =1

3, E[X ] =

2

3.

SECTION 4.4. Sum of a Random Number of Independent RandomVariables

Problem 21. At a certain time, the number of people that enter an elevator isa random variable with Poisson PMF, with parameter λ. The weight of each personto get on the elevator is independent of each other person’s weight, and is uniformlydistributed between 100 and 200 lbs. Let Xi be the fraction of 100 by which the ithperson exceeds 100 lbs, e.g. if the 7th person weighs 175 lbs., then X7 = 0.75. Let Ybe the sum of the Xi.

(a) Find the transform of Y .

(b) Use the transform to compute the expected value of Y .

(c) Verify your answer of (b) by using the law of iterated expectations.

Solution. (a) Let N be the number of people that enter the elevator. Its transform is

MN (s) = eλ(es−1). Let MX(s) be the common transform of the random variables Xi.Since Xi is uniformly distributed within [0, 1], we have

MX(s) =es − 1

s.

The transform MY (s) is found by starting with the transform MN (s) and replacingeach occurrence of es with MX(s). Thus,

MY (s) = eλ(MX(s)−1) = eλ(

es−1s −1

).

Page 282: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

60 Further Topics on Random Variables and Expectations Chap. 4

(b) We have using the chain rule

E[Y ] =d

dsMY (s)

∣∣∣∣∣s=0

=d

dsMX(s)

∣∣∣∣∣s=0

· λeλ(MX(s)−1)

∣∣∣∣∣s=0

=1

2· λ =

λ

2,

where we have used the fact that MX(0) = 1.

(c) From the law of iterated expectations we obtain

E[Y ] = E[E[Y |N ]

]= E

[NE[X ]

]= E[N ]E[X ] =

λ

2.

Problem 22. A motorist is going through 4 lights, each of which is found to bered with probability 1/2. The waiting times at each light are modeled as independentnormal random variables with mean 1 minute and standard deviation 1/2 minute. LetX be the total waiting time at the red lights.

(a) Use the total probability theorem to find the transform of X and the probabilitythat X exceeds 4 minutes. Is X normal?

(b) Find the transform of X by viewing X as a random sum of random variables.

Solution. (a) Using the total probability theorem, we have

P(X > 4) =

4∑

k=0

P(k lights are red)P(X > 4 | k lights are red).

We have

P(k lights are red) =

(4

k

)(1

2

)4

.

The conditional PDF of X given that k lights are red, is normal with mean k minutesand standard deviation (1/2)

√k. X is a mixture of normal random variables and the

transform of its (unconditional) PDF is the corresponding mixture of the transformsof the (conditional) normal PDFs. However, X is not normal, because a mixture ofnormal PDFs need not be normal. The probability P(X > 4 | k lights are red) can becomputed from the normal tables for each k, and P(X > 4) is obtained by substitutingthe results in the total probability formula above.

(b) Let K be the number of traffic lights that are found to be red. We can view X asthe sum of K independent normal random variables. Thus the transform of X can befound by replacing in the binomial transform MK(s) = (1/2+(1/2)es)4 the occurrenceof es by the normal transform corresponding to µ = 1 and σ = 1/2. Thus

MX(s) =

(1

2+

1

2

(e

(1/2)2s2

2 +s

))4

.

Note that by using the random sum argument of this part, we cannot easily obtain theprobability P(X > 4).

Page 283: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 61

Problem 23. The number C of customers who visit an internet bookstore in a dayis Poisson-distributed with parameter λ. The number B of books purchased by anycustomer is Poisson-distributed with parameter µ. The random variables C and Bare independent. The bookstore wants to increase by 10% the expected value of thenumber of books sold per day. Can this be done either by increasing λ by 10% whilekeeping µ unchanged, or by increasing µ by 10% while keeping λ unchanged? Which ofthese possibilities leads to the smallest variance in the number of books sold per day?

Solution. Let Bi be the number of books purchased by the ith customer, and let T bethe number of books sold in a day. Then

T = B1 + B2 + . . . + BC

and T is the sum of a random number of independently and identically distributedrandom variables. Therefore, the mean and variance of T can be found using the meanand variance of C and Bi. In particular, we have

E[T ] = E[C]E[B], var(T ) = E[C]var(B) + E[B]2var(C).

Since C and B have Poisson PMFs,

E[C] = var(C) = λ, E[B] = var(B) = µ.

Therefore,E[T ] = λµ

and it is indeed true that the bookstore can obtain a 10% increase in E[T ] by eitherincreasing λ by 10%, or by increasing µ by 10%.

The variance of T is

var(T ) = λµ + µ2λ = λµ(1 + µ).

If we increase µ by 10%, the variance of the number of books sold is

1.1λµ(1 + 1.1µ)

If we increase λ by 10%, the variance is

1.1λµ(1 + µ).

Hence the smallest variance is obtained when λ is increased by 10%.

Problem 24. Construct an example to show that the sum of a random number ofnormal random variables is not normal (even though a fixed sum is).

Solution. Take X and Y to be normal with means 1 and 2, respectively, and very smallvariances. Then the random variable that takes the value of X with some probabilityp and the value of Y with probability 1 − p takes values near 1 and 2 with relativelyhigh probability, but takes values near its mean (which is 3 − 2p) with relatively lowprobability. Thus, this random variable need not be normal.

Page 284: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

62 Further Topics on Random Variables and Expectations Chap. 4

Now let N be a random variable taking only the values 1 and 2 with probabilitiesp and 1 − p, respectively. The sum of a number N of normal random variables withmean equal to 1 and very small variance is a mixture of the type discussed above, whichneed not be normal.

Problem 25. * Use transforms to show that the sum of a Poisson-distributed numberof independent, identically distributed random variables is Poisson.

Solution. Let N be a Poisson-distributed random variable with parameter λ. Let Xi,i = 1, . . . ,N , be independent Bernoulli random variables with success probability p,and let

L = X1 + · · · + XN

be the corresponding random sum. The transform of L is found by starting with thetransform associated with N , which is

MN (s) = eλ(es−1),

and replacing each occurrence of es by the transform associated with Xi, which is

MX(s) = 1 − p + pes.

We obtainML(s) = eλ(1−p+pes−1) = eλp(es−1).

This is the transform of a Poisson random variable with parameter λp.

Problem 26. * A coin that comes up heads with probability p is tossed repeatedlyand independently.

(a) Find the transform of the total number of tosses until two heads come up ina row by using the fact that the sum of a geometrically distributed number ofindependent, identically distributed, geometric random variables is geometricallydistributed (cf. Example 4.23).

(b) Use a related argument to find the transform of the total number of tosses untilthree heads come up in a row.

Solution. (a) The head/tail sequence generated has the form

T · · · THT · · ·THT · · · · · ·HT · · · THH

The number of tail strings is geometrically distributed with parameter p. The num-ber of tosses corresponding to a tail string followed by a head (i.e., T · · · TH) is alsogeometric with parameter p. Counting the very last head in the entire sequence, wesee that the total number of tosses is Z = 1 + Y , where Y is the sum of geometricallydistributed number of geometric random variables. By the result of Example 4.23, Yis geometrically distributed with parameter p2. Thus the PMF of Z = 1 + Y is

pZ(k) =

p2(1− p2)k−2 if k = 2, 3, . . .,0 otherwise.

The transform of Z is

MZ(s) = es p2es

1− (1− p2)es=

p2e2s

1 − (1− p2)es.

Page 285: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 63

(b) The head/tail sequence generated is a geometrically distributed number (with pa-rameter p) of strings of the form of part (a) plus a final head to complete a 3-headsequence. Thus, if W is the corresponding number of tosses, we have

W = 1 + Z1 + · · · + ZN ,

where Z1, . . . , ZN are independent random variables that are distributed like the ran-dom variable Z of part (a), and N is geometrically distributed with parameter p.Therefore,

MW (s) = es

(pMZ(s)

1 − (1− p)MZ(s)

),

where MZ(s) is the transform found in part (a).

SECTION 4.5. Covariance and Correlation

Problem 27. Consider four random variables, W , X, Y , Z, with

E[W ] = E[X ] = E[Y ] = E[Z] = 0,

var(W ) = var(X) = var(Y ) = var(Z) = 1,

and assume that W , X, Y , Z are pairwise uncorrelated. Find the correlation coefficientsof ρ(A, B) and ρ(A, C), where A = W + X, B = X + Y , and C = Y + Z.

Solution. We have

cov(A, B) = E[AB] −E[A]E[B] = E[WX + WY + X2 + XY ] = E[X2] = 1,

and

var(A) = var(B) = 2,

so

ρ(A, B) =cov(A, B)√var(A)var(B)

=1

2.

We also have

cov(A, C) = E[AC ]− E[A]E[C] = E[WY + WZ + XY + XZ] = 0,

so that

ρ(A, C) = 0.

Problem 28. * Schwartz inequality. Show that if X and Y are random variables,we have (

E[XY ])2 ≤ E[X2]E[Y 2].

Page 286: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

64 Further Topics on Random Variables and Expectations Chap. 4

Solution. We have

0 ≤ E

[(X − E[XY ]

E[Y 2]Y

)2]

= E

[X2 − 2

E[XY ]

E[Y 2]XY +

E[XY ]2

E[Y 2]2Y 2

]

= E[X2]− 2E[XY ]

E[Y 2]E[XY ] +

E[XY ]2

E[Y 2]2E[Y 2]

= E[X2]− E[XY ]2

E[Y 2],

i.e.,(E[XY ]

)2 ≤ E[X2]E[Y 2].

Problem 29. * Correlation coefficient. Consider the correlation coefficient

ρ(X,Y ) =cov(X,Y )√var(X)var(Y )

of two random variables X and Y . Show that:

(a) |ρ(X, Y )| ≤ 1. Hint : Use the Schwartz inequality, cf. the preceding problem.

(b) If for all possible pairs of values (x, y), y−E[Y ] is a positive (or negative) multipleof x − E[X ], then ρ(X,Y ) = 1 [or ρ(X,Y ) = −1, respectively]. Hint : Use theanalysis of Example 4.20.

(c) If ρ(X,Y ) = 1 [or ρ(X,Y ) = −1], then for all possible pairs of values (x, y),y − E[Y ] is a positive (or negative, respectively) multiple of x− E[X ].

Solution. (a) Let X = X − E[X] and Y = Y − E[Y ]. Using the Schwartz inequality,we get

(ρ(X, Y )

)2=

E[XY ]2

E[X2]E[Y 2]≤ 1,

and hence |ρ(X,Y )| ≤ 1.

(b) If Y = aX , then

ρ(X, Y ) =E[XaX ]√

E[X2]E[(aX)2]=

a

|a| .

(c) If(ρ(X,Y )

)2= 1, then

E

[(X − E[XY ]

E[Y 2]Y

)2]

= E

[X

2 − 2E[XY ]

E[Y 2]XY +

E[XY ]2

E[Y 2]2Y

2

]

= E[X2]− 2E[XY ]

E[Y 2]E[XY ] +

E[XY ]2

E[Y 2]2E[Y 2]

= E[X2]− E[XY ]2

E[Y 2]

= E[X2](1 −

(ρ(X,Y )

)2)

= 0.

Page 287: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 65

Thus X − E[XY ]

E[Y 2]Y is a constant, which must be zero because E[X] = E[Y ] = 0. It

follows that

X =E[XY ]

E[Y 2]Y =

√E[X2]

E[Y 2]ρ(X, Y )Y ,

i.e., the sign of the constant ratio of X and Y is determined by the sign of ρ(X, Y ).

SECTION 4.6. Least Squares Estimation

Problem 30. A police radar always overestimates the speed of incoming cars byan amount that is uniformly distributed between 0 and 5 miles/hour. Assume that carspeeds are uniformly distributed from 55 to 75 miles/hour. What is the least squaresestimator of the car speed based on the radar’s measurement?

Solution. Let X be the car speed and let Y be the radar’s measurement. Similar toExample 4.27, the joint PDF of X and Y is uniform in the range of pairs (x, y) suchthat x ∈ [55, 75] and x ≤ y ≤ x + 5. We have similar to Example 4.27,

E[X |Y ] =

y2 + 27.5 if 55 ≤ y ≤ 60,y − 2.5 if 60 ≤ y ≤ 75,y2 + 35 if 75 ≤ y ≤ 80,0 otherwise.

Problem 31. A carton contains a number of boxes and each box independentlycontains a number of gadgets that is Poisson-distributed with parameter λ.

(a) We open a carton and count the number of boxes in the carton. What is theleast squares estimate of the number of gadgets in the carton given our count.

(b) We open a carton and use computer vision to count the number of boxes in thecarton. The computer may overcount or undercount this number by as much as2 boxes. In particular, the computer returns this number as n + W , where nis the correct number and W is a uniformly distributed integer-valued randomvariable in the interval [−2, 2]. What is the least squares estimate of the numberof gadgets in the carton given the computer’s count.

Solution. (a) Let Xi be the number of gadgets in the ith box. The number of gadgetsin the carton is

Y = X1 + · · · + XN ,

where N is the number of boxes in the carton. The expected number of gadgets ineach box is E[X] = λ. Thus, we have

E[Y |N = n] = nE[X ] = nλ.

(b) Let C = N + W be the computer’s count. We have

E[Y |C = c] =

2∑

i=−2

P(W = i)E[Y |C = c, W = i] =1

5

c+2∑

n=c−2

nλ = cλ.

Page 288: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

66 Further Topics on Random Variables and Expectations Chap. 4

Problem 32. * Let X and Y be two random variables with positive variances, andlet ρ be their correlation coefficient.

(a) Show that ρ = −1 if and only if there exists a constant b and a negative constanta such that Y = aX + b.

(b) Let XL be the linear least mean squares estimator of X based on Y . Show thatE[(X − X)Y ] = 0. Use this property to show that the estimation error X − XL

is uncorrelated with Y .

(b) Let X = E[X | Y ] be the least mean squares estimator of X given Y . Show thatE[(X − X)h(Y )] = 0 for any function h.

(d) Is it true that the estimation error X − E[X | Y ] is independent of Y ?

Solution. (a) Let U and V be the random variables

U =X − E[X]

σX, V =

Y − E[Y ]

σY.

Suppose there exists a scalar b and a negative scalar a such that Y = aX + b. We haveE[Y ] = aE[X] + b and var(Y ) = a2var(X). Therefore, σY = −aσX (since a < 0). Weobtain

ρ = E[UV ]

= E

[X − E[X ]

σX

Y − E[Y ]

σY

]

= E

[X − E[X ]

σX

(aX + b− aE[X] − b)

−aσX

]

= E

[X − E[X ]

σX

X − E[X]

−σX

]

= E[−U2]

= −E[U2]

= −1.

Now suppose that ρ = E[UV ] = −1. We observe that E[U ] = E[V ] = 0 andE[U2] = E[V 2] = 1. We have

E[(U − E[UV ]V )2] =

∫ ∞

−∞

∫ ∞

−∞(u− E[UV ]v)2fU,V (u, v)dudv ≥ 0.

Since the integrand is nonnegative, it must be identically zero in order for the integral tobe zero, i.e., U = E[UV ]V = −V or Y = aX+b where a =

σYσX

and b = E[Y ]− σYσX

E[X].

We now claim that E[(U − E[UV ]V )2] = 0. Indeed, we have

E[(U − E[UV ]V )

2]

= E[U2] − 2(E[UV ])

2+

(E[UV ]

)2E[V

2]

= 1−(E[UV ]

)2

= 0.

This completes the proof.

Page 289: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 67

(b) We have

XL = E[X] +cov(X,Y )

σ2Y

(Y − E[Y ]

),

so

E[(X − XL)Y

]= E

[XY −

(E[X] +

cov(X, Y )

σ2Y

(Y −E[Y ]

))Y

]

= E

[XY − E[X]Y − cov(X,Y )

σ2Y

(Y 2 − Y E[Y ]

)]

= E[XY ] −E[X ]E[Y ]− cov(X, Y )E[Y 2]

σ2Y

+cov(X, Y )E[Y ]2

σ2Y

= cov(X,Y )

[1 − E[Y 2]

σ2Y

+E[Y ]2

σ2Y

]

= cov(X,Y )

[1 − σ2

Y

σ2Y

]

= 0.

Now, let us consider the correlation of the estimation error X − XL with Y . Since

ρ =cov(X − XL, Y )

σX−XLσY

,

we must show that cov(X − XL, Y ) = 0. We have

cov(X − XL, Y ) = E[(X − XL)Y

]− E[X − XL]E[Y ] = −E[X − XL]E[Y ]

and

E[X − XL] = E

[X − E[X ]− cov(X, Y )

σ2Y

(Y − E[Y ])

]

= E[X] − E[X]− cov(X, Y )

σ2Y

E[Y − E[Y ]

]

= 0.

The desired property follows.

(c) We haveE

[(X − X)h(Y )

]= E

[(X − E[X |Y ]

)h(Y )

],

by the definition of X . Now using the linearity of expectation, we obtain

E[Xh(Y )

]− E

[E

[X | Y

]h(Y )

]= E

[Xh(Y )

]− E

[E[Xh(Y ) |Y ]

]

= E[Xh(Y )

]− E

[Xh(Y )

]

= 0,

where the first equality is obtained by noticing that E[X | Y ] is taken with respect toX, thus allowing h(Y ) to be pulled into the expectation. The second equality resultsfrom the law of iterated expectations.

Page 290: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

68 Further Topics on Random Variables and Expectations Chap. 4

(d) The answer is no. For a counterexample, let X and Y be discrete random variableswith the joint PMF

pX,Y (x, y) =

14

for (x, y) = (1, 0), (0, 1), (−1, 0), (0,−1)0 otherwise.

Note that E[X | Y = y] = 0 for all possible values y, so E[X |Y ] = 0. (More precisely,E[X | Y ] is a random variable that equals zero with probability one.) Thus, we haveX −E[X |Y ] = X (where the equality refers to equality in distribution). Since X andY are not independent, X − E[X |Y ] and Y are also not independent.

SECTION 4.7. The Bivariate Normal Distribution

Problem 33. Let X1 and X2 be independent standard normal random variables.Define the random variables Y1 and Y2 by

Y1 = 2X1 + X2, Y2 = X1 −X2.

Find µY1 , µY2 , cov(Y1, Y2) and then write the joint PDF fY1,Y2 (y1, y2).

Solution. The means are given by

E[Y1] = E[2X1 + X2] = E[2X1] + E[X2] = 0,

E[Y2] = E[X1 −X2] = E[X1] − E[X2] = 0.

The covariance is obtained as follows:

cov(Y1, Y2) = E[Y1Y1] − µY1µY2

= E[(2X1 + X2) · (X1 −X2)

]

= E[2X2

1 −X1X2 −X22

]

= 1.

The bivariate normal is determined by the means, the variance, and the correlationcoefficient, so we need to calculate the variances. We have

σ2Y1

= E[Y 21 ]− µ2

Y1= E[4X2

1 + 4X1X2 + X22 ] = 5.

Similarly,σ2

Y2= E[Y 2

2 ]− µ2Y2

= 5.

Thus

ρ(Y1, Y2) =cov(Y1, Y2)

σY1σY2

=1

5.

To write the PDF of (Y1, Y2) we substitute the above values into the bivariate densityfunction.

Problem 34. The coordinates (X, Y ) of a point on the plane have a bivariatenormal joint distribution with µX = µY = 0, ρ = 0, and σ2

X = σ2Y = σ2. Given that

Page 291: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 69

the point is at least at distance c from the origin, find the conditional joint densityfunction for X,Y .

Solution. Let C denote the event that X2 + Y 2 > c. Then,

P(C) =1

2πσ2

∫ 2π

0

∫ ∞

c

re− r2

2σ2 drdθ

=1

σ2

∫ ∞

c

re− r2

2σ2 dr

= e− c2

2σ2 ,

and for (x, y) ∈ C,

fXY |C(x, y |C) =1

2πσ2exp

− 1

2σ2(x

2+ y

2 − c2)

.

Problem 35. Suppose that X is a standard normal random variable, and that therandom variable Z takes the values 0 or 1 with equal probability. Consider a randomvariable Y such that

Y =

X if z = 1,−X if z = 0.

(a) Are X and Y independent?

(b) Are Y and Z independent?

(c) Show that Y is a standard normal random variable.

(d) Show that cov(X, Y ) = 0.

Solution. (a) X and Y cannot be independent, since given X we know that Y can takeone of two values that depend on the value of X.

(b) Y and Z are independent because X is symmetric relative to the origin.

(c) We have

fY,Z(y, z) = fY |Z(y | z) · fZ(z)

= fX(x) · fZ(z),

so that

fY (y) =∑

I

fX(x) · fZ(z) = fX(x),

and therefore Y is standard normal.

Page 292: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

70 Further Topics on Random Variables and Expectations Chap. 4

(d) We want to show that cov(X,Y ) = 0. Since E[X] = E[Y ] = 0, we have

cov(X,Y ) =

∫ ∞

−∞

∫ ∞

−∞xyfXY (x, y)dxdy

=

∫ ∞

−∞

∫ ∞

−∞xyfY |X(y | x) · fX(x)dxdy

=

∫ ∞

−∞

∫ ∞

−∞xyfX(x)

1

2(δ(x) + δ(−x))dxdy

=1

2

∫ ∞

−∞y[xfX(x)− xfX(−x)]dy

= 0

as required. The last equality follows from the fact that since X is a standard nor-mal random variable, we have fX(x) = fX(−x). Note that we have two dependentnormal random variables X, Y that have zero correlation. There is a small subtletyhere. We know that if two random variables have bivariate joint distribution, and areuncorrelated, then they are independent. However in this case, we have two dependentnormal random variables, whose correlation is zero. The difference here is that thejoint distribution is not bivariate normal.

Problem 36. Suppose that X is a standard normal random variable.

(a) Find the third and fourth moments of X.

(b) Define a new random variable Y such that

Y = a + bX + cX2.

Find the correlation coefficient ρ(X,Y ).

Solution. (a) The transform of X is

MX(s) = e12 s2 .

By taking derivatives with respect to s, and find that

E[X] = 0, E[X2] = 1, E[X3] = 0, E[X4] = 3.

(b) To compute the correlation coefficient

ρ(X, Y ) =cov(X, Y )

σXσY,

we first compute the covariance:

cov(X, Y ) = E[XY ]− E[X]E[Y ]

= E[aX + bX2 + cX3] − E[X]E[Y ]

= aE[X ] + bE[X2] + cE[X3]

= b.

Page 293: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 4.7 The Bivariate Normal Distribution 71

Now var(X) = 1 so that σX = 1. We have

var(Y ) = var(a + bX + cX2)

= E[(a + bX + cX2)2

]−

(E[a + bX + cX2]

)2

= (a2

+ 2ac + b2

+ 3c2) − (a

2+ c

2+ 2ac)

= b2 + 2c2

and therefore

ρ(X, Y ) =b√

b2 + 2c2.

Problem 37. * Let X and Y have a bivariate normal distribution. Show that σ2X |Y

is independent of Y .

Solution. We haveσ2

X | Y =(1− ρ(X,Y )2

)σ2

X ,

which does not depend on the experimental value of Y .

Page 294: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

5

Stochastic Processes

Contents

5.1. The Bernoulli Process . . . . . . . . . . . . . . . . . . . p. 35.2. The Poisson Process . . . . . . . . . . . . . . . . . . p. 15

1

Page 295: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

2 Stochastic Processes Chap. 5

A stochastic process is a mathematical model of a probabilistic experiment thatevolves in time and generates a sequence of numerical values. For example, astochastic process can be used to model:

(a) the sequence of daily prices of a stock;

(b) the sequence of scores in a football game;

(c) the sequence of failure times of a machine;

(d) the sequence of hourly traffic loads at a node of a communication network;

(e) the sequence of radar measurements of the position of an airplane.

Each numerical value in the sequence is modeled by a random variable, so astochastic process is simply a (finite or infinite) sequence of random variablesand does not represent a major conceptual departure from our basic framework.We are still dealing with a single basic experiment that involves outcomes gov-erned by a probability law, and random variables that inherit their probabilisticproperties from that law.† However, stochastic processes involve some change inemphasis over our earlier models. In particular:

(a) We tend to focus on the dependencies in the sequence of values generatedby the process. For example, how do future prices of a stock depend onpast values?

(b) We are often interested in long-term averages, involving the entire se-quence of generated values. For example, what is the fraction of time thata machine is idle?

(c) We sometimes wish to characterize the likelihood or frequency of certainboundary events. For example, what is the probability that within agiven hour all circuits of some telephone system become simultaneouslybusy, or what is the frequency with which some buffer in a computer net-work overflows with data?

In this book, we will discuss two major categories of stochastic processes.

(a) Arrival-Type Processes: Here, we are interested in occurrences that havethe character of an “arrival,” such as message receptions at a receiver, jobcompletions in a manufacturing cell, customer purchases at a store, etc.We will focus on models in which the interarrival times (the times betweensuccessive arrivals) are independent random variables. In Section 5.1, weconsider the case where arrivals occur in discrete time and the interarrivaltimes are geometrically distributed – this is the Bernoulli process. In Sec-tion 5.2, we consider the case where arrivals occur in continuous time and

† Let us emphasize that all of the random variables arising in a stochastic processrefer to a single and common experiment, and are therefore defined on a commonsample space. The corresponding probability law can be specified directly or indirectly(by assuming some of its properties), as long as it unambiguously determines the jointCDF of any subset of the random variables involved.

Page 296: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.1 The Bernoulli Process 3

the interarrival times are exponentially distributed – this is the Poissonprocess.

(b) Markov Processes : Here, we are looking at experiments that evolve in timeand in which the future evolution exhibits a probabilistic dependence onthe past. As an example, the future daily prices of a stock are typicallydependent on past prices. However, in a Markov process, we assume a veryspecial type of dependence: the next value depends on past values onlythrough the current value. There is a rich methodology that applies tosuch processes, and which will be developed in Chapter 6.

5.1 THE BERNOULLI PROCESS

The Bernoulli process can be visualized as a sequence of independent coin tosses,where the probability of heads in each toss is a fixed number p in the range0 < p < 1. In general, the Bernoulli process consists of a sequence of Bernoullitrials, where each trial produces a 1 (a success) with probability p, and a 0 (afailure) with probability 1− p, independently of what happens in other trials.

Of course, coin tossing is just a paradigm for a broad range of contextsinvolving a sequence of independent binary outcomes. For example, a Bernoulliprocess is often used to model systems involving arrivals of customers or jobs atservice centers. Here, time is discretized into periods, and a “success” at the kthtrial is associated with the arrival of at least one customer at the service centerduring the kth period. In fact, we will often use the term “arrival” in place of“success” when this is justified by the context.

In a more formal description, we define the Bernoulli process as a sequenceX1,X2, . . . of independent Bernoulli random variables Xi with

P(Xi = 1) = P(success at the ith trial) = p,

P(Xi = 0) = P(failure at the ith trial) = 1− p,

for each i.†Given an arrival process, one is often interested in random variables such

as the number of arrivals within a certain time period, or the time until the firstarrival. For the case of a Bernoulli process, some answers are already availablefrom earlier chapters. Here is a summary of the main facts.

† Generalizing from the case of a finite number of random variables, the inde-pendence of an infinite sequence of random variables Xi is defined by the requirementthat the random variables X1, . . . ,Xn be independent for any finite n. Intuitively,knowing the experimental values of any finite subset of the random variables does notprovide any new probabilistic information on the remaining random variables, and theconditional distribution of the latter stays the same as the unconditional one.

Page 297: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

4 Stochastic Processes Chap. 5

Some Random Variables Associated with the Bernoulli Processand their Properties

• The binomial with parameters p and n. This is the number S ofsuccesses in n independent trials. Its PMF, mean, and variance are

pS(k) =

(n

k

)pk(1− p)n−k, k = 0, 1, . . . , n,

E[S] = np, var(S) = np(1− p).

• The geometric with parameter p. This is the number T of trialsup to (and including) the first success. Its PMF, mean, and varianceare

pT (t) = (1 − p)t−1p, t = 1, 2, . . . ,

E[T ] =1

p, var(T ) =

1− p

p2.

Independence and Memorylessness

The independence assumption underlying the Bernoulli process has importantimplications, including a memorylessness property (whatever has happened inpast trials provides no information on the outcomes of future trials). An appreci-ation and intuitive understanding of such properties is very useful, and allows forthe quick solution of many problems that would be difficult with a more formalapproach. In this subsection, we aim at developing the necessary intuition.

Let us start by considering random variables that are defined in terms ofwhat happened in a certain set of trials. For example, the random variableZ = (X1 + X3)X6X7 is defined in terms of the first, third, sixth, and seventhtrial. If we have two random variables of this type and if the two sets of trialsthat define them have no common element, then these random variables areindependent. This is a generalization of a fact first seen in Chapter 2: if tworandom variables U and V are independent, then any two functions of them,g(U) and h(V ), are also independent.

Example 5.1.

(a) Let U be the number of successes in trials 1 to 5. Let V be the number ofsuccesses in trials 6 to 10. Then, U and V are independent. This is becauseU = X1 + · · ·+X5, V = X6 + · · ·+X10, and the two collections X1, . . . ,X5,X6, . . . ,X10 have no common elements.

Page 298: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.1 The Bernoulli Process 5

(b) Let U (respectively, V ) be the first odd (respectively, even) time i in which wehave a success. Then, U is determined by the odd-time sequence X1,X3, . . .,whereas V is determined by the even-time sequence X2,X4, . . .. Since thesetwo sequences have no common elements, U and V are independent.

Suppose now that a Bernoulli process has been running for n time steps,and that we have observed the experimental values of X1, X2, . . . ,Xn. We no-tice that the sequence of future trials Xn+1,Xn+2, . . . are independent Bernoullitrials and therefore form a Bernoulli process. In addition, these future trials areindependent from the past ones. We conclude that starting from any given pointin time, the future is also modeled by a Bernoulli process, which is independentof the past. We refer to this as the fresh-start property of the Bernoulli process.

Let us now recall that the time T until the first success is a geometricrandom variable. Suppose that we have been watching the process for n timesteps and no success has been recorded. What can we say about the number T−nof remaining trials until the first success? Since the future of the process (aftertime n) is independent of the past and constitutes a fresh-starting Bernoulliprocess, the number of future trials until the first success is described by thesame geometric PMF. Mathematically, we have

P(T − n = t |T > n) = (1 − p)t−1p = P(T = t), t = 1, 2, . . . .

This memorylessness property can also be derived algebraically, using thedefinition of conditional probabilities, but the argument given here is certainlymore intuitive.

Memorylessness and the Fresh-Start Property of the BernoulliProcess

• The number T − n of trials until the first success after time n hasa geometric distribution with parameter p, and is independent of thepast.

• For any given time n, the sequence of random variables Xn+1, Xn+2, . . .(the future of the process) is also a Bernoulli process, and is indepen-dent from X1, . . . , Xn (the past of the process).

The next example deals with an extension of the fresh-start property, inwhich we start looking at the process at a random time, determined by the pasthistory of the process.

Example 5.2. Let N be the first time in which we have a success immediatelyfollowing a previous success. (That is, N is the first i for which Xi−1 = Xi = 1.)What is the probability P(XN+1 = XN+2 = 0) that there are no successes in thetwo trials that follow?

Page 299: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

6 Stochastic Processes Chap. 5

Intuitively, once the condition XN−1 = XN = 1 is satisfied, from then on,the future of the process still consists of independent Bernoulli trials. Therefore theprobability of an event that refers to the future of the process is the same as in afresh-starting Bernoulli process, so that P(XN+1 = XN+2 = 0) = (1− p)2.

To make this argument precise, we argue that the time N is a random variable,and by conditioning on the possible values of N , we have

P(XN+1 = XN+2 = 0) =∑

n

P(N = n)P(XN+1 = XN+2 = 0 |N = n)

=∑

n

P(N = n)P(Xn+1 = Xn+2 = 0 |N = n)

Because of the way that N was defined, the event N = n occurs if and only ifthe experimental values of X1, . . . , Xn satisfy a certain condition. But the latterrandom variables are independent of Xn+1 and Xn+2. Therefore,

P(Xn+1 = Xn+2 = 0 |N = n) = P(Xn+1 = Xn+2 = 0) = (1− p)2,

which leads to

P(XN+1 = XN+2 = 0) =∑

n

P(N = n)(1− p)2 = (1− p)2.

Interarrival Times

An important random variable associated with the Bernoulli process is the timeof the kth success, which we denote by Yk. A related random variable is the kthinterarrival time, denoted by Tk. It is defined by

T1 = Y1, Tk = Yk − Yk−1, k = 2, 3, . . .

and represents the number of trials following the k − 1st success until the nextsuccess. See Fig. 5.1 for an illustration, and also note that

Yk = T1 + T2 + · · ·+ Tk.

1

TimeT1

0 10 0 0 0 0 0 01 1 0

T2 T3 T4

Y3

Figure 5.1: Illustration of interarrival times. In this example, T1 = 3, T2 = 5,T3 = 2, T4 = 1. Furthermore, Y1 = 3, Y2 = 8, Y3 = 10, Y4 = 11.

Page 300: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.1 The Bernoulli Process 7

We have already seen that the time T1 until the first success is a geometricrandom variable with parameter p. Having had a success at time T1, the futureis a fresh-starting Bernoulli process. Thus, the number of trials T2 until thenext success has the same geometric PMF. Furthermore, past trials (up to andincluding time T1) are independent of future trials (from time T1 + 1 onward).Since T2 is determined exclusively by what happens in these future trials, wesee that T2 is independent of T1. Continuing similarly, we conclude that therandom variables T1, T2, T3, . . . are independent and all have the same geometricdistribution.

This important observation leads to an alternative, but equivalent way ofdescribing the Bernoulli process, which is sometimes more convenient to workwith.

Alternative Description of the Bernoulli Process

1. Start with a sequence of independent geometric random variables T1,T2, . . ., with common parameter p, and let these stand for the interar-rival times.

2. Record a success (or arrival) at times T1, T1 + T2, T1 + T2 + T3, etc.

Example 5.3. A computer executes two types of tasks, priority and nonpriority,and operates in discrete time units (slots). A priority task arises with probabilityp at the beginning of each slot, independently of other slots, and requires one fullslot to complete. A nonpriority task is executed at a given slot only if no prioritytask is available. In this context, it may be important to know the probabilisticproperties of the time intervals available for nonpriority tasks.

With this in mind, let us call a slot busy if within this slot, the computerexecutes a priority task, and otherwise let us call it idle. We call a string of idle(or busy) slots, flanked by busy (or idle, respectively) slots, an idle period (or busyperiod , respectively). Let us derive the PMF, mean, and variance of the followingrandom variables (cf. Fig. 5.2):

(a) T = the time index of the first idle slot;

(b) B = the length (number of slots) of the first busy period;

(c) I = the length of the first idle period.

We recognize T as a geometrically distributed random variable with param-eter 1 − p. Its PMF is

pT (k) = pk−1(1− p), k = 1, 2, . . . .

Its mean and variance are

E[T ] =1

1 − p, var(T ) =

p

(1− p)2.

Page 301: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

8 Stochastic Processes Chap. 5

TimeBusyPeriod

B IB B B B B BI I BI I I

T IdlePeriod

Time

I B B B BI I BI I I

T

II I

B I

I B

Z

Z

Figure 5.2: Illustration of busy (B) and idle (I) periods in Example 5.3. Inthe top diagram, T = 4, B = 3, and I = 2. In the bottom diagram, T = 1,I = 5, and B = 4.

Let us now consider the first busy period. It starts with the first busy slot,call it slot L. (In the top diagram in Fig. 5.2, L = 1; in the bottom diagram, L = 6.)The number Z of subsequent slots until (and including) the first subsequent idleslot has the same distribution as T , because the Bernoulli process starts fresh attime L + 1. We then notice that Z = B and conclude that B has the same PMFas T .

If we reverse the roles of idle and busy slots, and interchange p with 1−p, wesee that the length I of the first idle period has the same PMF as the time indexof the first busy slot, so that

pI(k) = (1− p)k−1p, k = 1, 2, . . . , E[I] =1

p, var(I) =

1− p

p2.

We finally note that the argument given here also works for the second, third,etc. busy (or idle) period. Thus the PMFs calculated above apply to the ith busyand idle period, for any i.

The kth Arrival Time

The time Yk of the kth success is equal to the sum Yk = T1 + T2 + · · ·+ Tk of kindependent identically distributed geometric random variables. This allows usto derive formulas for the mean, variance, and PMF of Yk, which are given inthe table that follows.

Page 302: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.1 The Bernoulli Process 9

Properties of the kth Arrival Time

• The kth arrival time is equal to the sum of the first k interarrival times

Yk = T1 + T2 + · · ·+ Tk,

and the latter are independent geometric random variables with com-mon parameter p.

• The mean and variance of Yk are given by

E[Yk] = E[T1] + · · ·+ E[Tk] =k

p,

var(Yk) = var(T1) + · · ·+ var(Tk) =k(1 − p)

p2.

• The PMF of Yk is given by

pYk(t) =

(t− 1

k − 1

)pk(1− p)t−k, t = k, k + 1, . . . ,

and is known as the Pascal PMF of order k.

To verify the formula for the PMF of Yk, we first note that Yk cannot besmaller than k. For t ≥ k, we observe that the event Yk = t (the kth successcomes at time t) will occur if and only if both of the following two events A andB occur:

(a) event A: trial t is a success;

(b) event B: exactly k − 1 successes occur in the first t− 1 trials.

The probabilities of these two events are

P(A) = p

and

P(B) =

(t− 1

k − 1

)pk−1(1 − p)t−k,

respectively. In addition, these two events are independent (whether trial t is asuccess or not is independent of what happened in the first t−1 trials). Therefore,

pYk(t) = P(Yk = t) = P(A ∩B) = P(A)P(B) =

(t− 1

k − 1

)pk(1− p)t−k,

as claimed.

Page 303: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

10 Stochastic Processes Chap. 5

Example 5.4. In each minute of basketball play, Alice commits a single foul withprobability p and no foul with probability 1 − p. The number of fouls in differentminutes are assumed to be independent. Alice will foul out of the game once shecommits her sixth foul, and will play 30 minutes if she does not foul out. What isthe PMF of Alice’s playing time?

We model fouls as a Bernoulli process with parameter p. Alice’s playing timeZ is equal to Y6, the time until the sixth foul, except if Y6 is larger than 30, in whichcase, her playing time is 30, the duration of the game; that is, Z = minY6, 30.The random variable Y6 has a Pascal PMF of order 6, which is given by

pY6(t) =

(t− 1

5

)p6(1− p)t−6, t = 6, 7, . . .

To determine the PMF pZ(z) of Z, we first consider the case where z is between 6and 29. For z in this range, we have

pZ(z) = P(Z = z) = P(Y6 = z) =

(z − 1

5

)p6(1− p)z−6, z = 6, 7, . . . , 29.

The probability that Z = 30 is then determined from

pZ(30) = 1 −29∑

z=6

pZ(z).

Splitting and Merging of Bernoulli Processes

Starting with a Bernoulli process in which there is a probability p of an arrivalat each time, consider splitting it as follows. Whenever there is an arrival, wechoose to either keep it (with probability q), or to discard it (with probability1−q); see Fig. 5.3. Assume that the decisions to keep or discard are independentfor different arrivals. If we focus on the process of arrivals that are kept, we seethat it is a Bernoulli process: in each time slot, there is a probability pq of akept arrival, independently of what happens in other slots. For the same reason,the process of discarded arrivals is also a Bernoulli process, with a probabilityof a discarded arrival at each time slot equal to p(1− q).

In a reverse situation, we start with two independent Bernoulli processes(with parameters p and q, respectively) and merge them into a single process,as follows. An arrival is recorded in the merged process if and only if thereis an arrival in at least one of the two original processes, which happens withprobability p + q − pq [one minus the probability (1 − p)(1 − q) of no arrival ineither process.] Since different time slots in either of the original processes areindependent, different slots in the merged process are also independent. Thus,the merged process is Bernoulli, with success probability p + q− pq at each timestep; see Fig. 5.4.

Page 304: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.1 The Bernoulli Process 11

Time

Time

Time

Originalprocess

q

1 - q

Figure 5.3: Splitting of a Bernoulli process.

Time

Time

Time

Merged process:Bernoulli(p+q-pq)

Bernoulli(p)

Bernoulli(q)

Figure 5.4: Merging of independent Bernoulli process.

Splitting and merging of Bernoulli (or other) arrival processes arises inmany contexts. For example, a two-machine work center may see a stream ofarriving parts to be processed and split them by sending each part to a randomlychosen machine. Conversely, a machine may be faced with arrivals of differenttypes that can be merged into a single arrival stream.

The Poisson Approximation to the Binomial

The number of successes in n independent Bernoulli trials is a binomial randomvariable with parameters n and p, and its mean is np. In this subsection, weconcentrate on the special case where n is large but p is small, so that the meannp has a moderate value. A situation of this type arises when one passes fromdiscrete to continuous time, a theme to be picked up in the next section. Forsome more examples, think of the number of airplane accidents on any given day:

Page 305: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

12 Stochastic Processes Chap. 5

there is a large number of trials (airplane flights), but each one has a very smallprobability of being involved in an accident. Or think of counting the number oftypos in a book: there is a large number n of words, but a very small probabilityof misspelling each one.

Mathematically, we can address situations of this kind, by letting n growwhile simultaneously decreasing p, in a manner that keeps the product np at aconstant value λ. In the limit, it turns out that the formula for the binomial PMFsimplifies to the Poisson PMF. A precise statement is provided next, togetherwith a reminder of some of the properties of the Poisson PMF that were derivedin earlier chapters.

Poisson Approximation to the Binomial

• A Poisson random variable Z with parameter λ takes nonnegativeinteger values and is described by the PMF

pZ(k) = e−λλk

k!, k = 0, 1,2, . . . .

Its mean and variance are given by

E[Z] = λ, var(Z) = λ.

• For any fixed nonnegative integer k, the binomial probability

pS(k) =n!

(n− k)!k!pk(1 − p)n−k

converges to pZ(k), when we take the limit as n → ∞ and p = λ/n,while keeping λ constant.

• In general, the Poisson PMF is a good approximation to the binomialas long as λ = np, n is very large, and p is very small.

The verification of the limiting behavior of the binomial probabilities wasgiven in Chapter 2 as as an end-of-chapter problem, and is replicated here forconvenience. We let p = λ/n and note that

pS(k) =n!

(n− k)!k!pk(1− p)n−k

=n(n− 1) · · · (n− k + 1)

k!· λk

nk·(

1− λ

n

)n−k

.

Page 306: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.1 The Bernoulli Process 13

=n

n· (n− 1)

n· · · (n− k + 1)

n· λk

k!·(

1− λ

n

)n−k

.

Let us focus on a fixed k and let n → ∞. Each one of the ratios (n − 1)/n,

(n− 2)/n, . . . , (n− k + 1)/n converges to 1. Furthermore,†

(1− λ

n

)−k

→ 1,

(1− λ

n

)n

→ e−λ.

We conclude that for each fixed k, and as n →∞, we have

pS(k) → e−λλk

k!.

Example 5.5. As a rule of thumb, the Poisson/binomial approximation

e−λ λk

k!≈ n!

(n − k)!k!pk(1− p)n−k , k = 0, 1, . . . , n,

is valid to several decimal places if n ≥ 100, p ≤ 0.01, and λ = np. To check this,consider the following.

Gary Kasparov, the world chess champion (as of 1999) plays against 100 ama-teurs in a large simultaneous exhibition. It has been estimated from past experiencethat Kasparov wins in such exhibitions 99% of his games on the average (in preciseprobabilistic terms, we assume that he wins each game with probability 0.99, inde-pendently of other games). What are the probabilities that he will win 100 games,98 games, 95 games, and 90 games?

We model the number of games X that Kasparov does not win as a binomialrandom variable with parameters n = 100 and p = 0.01. Thus the probabilitiesthat he will win 100 games, 98, 95 games, and 90 games are

pX(0) = (1− 0.01)100 = 0.366,

pX(2) =100!

98!2!0.012(1− 0.01)98 = 0.185,

pX(5) =100!

95!5!0.015(1− 0.01)95 = 0.00290,

pX(10) =100!

90!10!0.01

10(1− 0.01)

90= 7.006× 10

−8,

† We are using here, the well known formula limx→∞(1 − 1x )x = e−1. Letting

x = n/λ, we have limn→∞(1 − λn )n/λ = e−1, from which it follows that limn→∞(1 −

λn )n = e−λ.

Page 307: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

14 Stochastic Processes Chap. 5

respectively. Now let us check the corresponding Poisson approximations with λ =100 · 0.01 = 1. They are:

pZ(0) = e−1 1

0!= 0.368,

pZ(2) = e−1 1

2!= 0.184,

pZ(5) = e−1 1

5!= 0.00306,

pZ(10) = e−1 1

10!= 1.001× 10−8.

By comparing the binomial PMF values pX(k) with their Poisson approximationspZ(k), we see that there is close agreement.

Suppose now that Kasparov plays simultaneously just 5 opponents, who are,however, stronger so that his probability of a win per game is 0.9. Here are thebinomial probabilities pX(k) for n = 5 and p = 0.1, and the corresponding Poissonapproximations pZ(k) for λ = np = 0.5,

pX(0) = 0.590, pZ(0) = 0.605,

pX(1) = 0.328, pZ(1) = 0.303,

pX(2) = 0.0729, pZ(2) = 0.0758,

pX(3) = 0.0081, pZ(3) = 0.0126,

pX(4) = 0.00045, pZ(4) = 0.0016,

pX(5) = 0.00001, pZ(5) = 0.00016.

We see that the approximation, while not poor, is considerably less accurate thanin the case where n = 100 and p = 0.01.

Example 5.6. A packet consisting of a string of n symbols is transmitted overa noisy channel. Each symbol has probability p = 0.0001 of being transmitted inerror, independently of errors in the other symbols. How small should n be in orderfor the probability of incorrect transmission (at least one symbol in error) to be lessthan 0.001?

Each symbol transmission is viewed as an independent Bernoulli trial. Thus,the probability of a positive number S of errors in the packet is

1−P(S = 0) = 1 − (1− p)n.

For this probability to be less than 0.001, we must have 1 − (1− 0.0001)n < 0.001or

n <ln 0.999

ln 0.9999= 10.0045.

We can also use the Poisson approximation for P(S = 0), which is e−λ with λ =np = 0.0001 · n, and obtain the condition 1− e−0.0001·n < 0.001, which leads to

n <− ln 0.999

0.0001= 10.005.

Given that n must be integer, both methods lead to the same conclusion that ncan be at most 10.

Page 308: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 15

5.2 THE POISSON PROCESS

The Poisson process can be viewed as a continuous-time analog of the Bernoulliprocess and applies to situations where there is no natural way of dividing timeinto discrete periods.

To see the need for a continuous-time version of the Bernoulli process, letus consider a possible model of traffic accidents within a city. We can start bydiscretizing time into one-minute periods and record a “success” during everyminute in which there is at least one traffic accident. Assuming the traffic in-tensity to be constant over time, the probability of an accident should be thesame during each period. Under the additional (and quite plausible) assumptionthat different time periods are independent, the sequence of successes becomes aBernoulli process. Note that in real life, two or more accidents during the sameone-minute interval are certainly possible, but the Bernoulli process model doesnot keep track of the exact number of accidents. In particular, it does not allowus to calculate the expected number of accidents within a given period.

One way around this difficulty is to choose the length of a time period to bevery small, so that the probability of two or more accidents becomes negligible.But how small should it be? A second? A millisecond? Instead of answeringthis question, it is preferable to consider a limiting situation where the length ofthe time period becomes zero, and work with a continuous time model.

We consider an arrival process that evolves in continuous time, in the sensethat any real number t is a possible arrival time. We define

P (k, τ) = P(there are exactly k arrivals during an interval of length τ),

and assume that this probability is the same for all intervals of the same lengthτ . We also introduce a positive parameter λ to be referred to as the arrivalrate or intensity of the process, for reasons that will soon be apparent.

Definition of the Poisson Process

An arrival process is called a Poisson process with rate λ if it has the fol-lowing properties:

(a) (Time-homogeneity.) The probability P (k, τ) of k arrivals is thesame for all intervals of the same length τ .

(b) (Independence.) The number of arrivals during a particular intervalis independent of the history of arrivals outside this interval.

(c) (Small interval probabilities.) The probabilities P (k, τ) satisfy

P (0, τ) = 1− λτ + o(τ),

P (1, τ) = λτ + o1(τ).

Page 309: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

16 Stochastic Processes Chap. 5

Here, o(τ) and o1(τ) are functions of τ that satisfy

limτ→0

o(τ)

τ= 0, lim

τ→0

o1(τ)

τ= 0.

The first property states that arrivals are “equally likely” at all times. Thearrivals during any time interval of length τ are statistically the same, in thesense that they obey the same probability law. This is a counterpart of theassumption that the success probability p in a Bernoulli process is constant overtime.

To interpret the second property, consider a particular interval [t, t′], oflength t′ − t. The unconditional probability of k arrivals during that intervalis P (k, t′ − t). Suppose now that we are given complete or partial informationon the arrivals outside this interval. Property (b) states that this informationis irrelevant: the conditional probability of k arrivals during [t, t′] remains equalto the unconditional probability P (k, t′ − t). This property is analogous to theindependence of trials in a Bernoulli process.

The third property is critical. The o(τ) and o1(τ) terms are meant to benegligible in comparison to τ , when the interval length τ is very small. They canbe thought of as the O(τ2) terms in a Taylor series expansion of P (k, τ). Thus,for small τ , the probability of a single arrival is roughly λτ , plus a negligibleterm. Similarly, for small τ , the probability of zero arrivals is roughly 1 − λτ .Note that the probability of two or more arrivals is

1− P (0, τ)− P (1, τ) = −o(τ) − o1(τ),

and is negligible in comparison to P (1, τ) as τ gets smaller and smaller.

Time0x x x

δ

Arrivals

probability of successper period:p =λδ

δ δδ δ δ δ δ

τ

number ofperiods:n=τ/δ

expected numberof arrivals:np=λτ

Figure 5.5: Bernoulli approximation of the Poisson process.

Let us now start with a fixed time interval of length τ and partition itinto τ/δ periods of length δ, where δ is a very small number; see Fig. 5.5. Theprobability of more than two arrivals during any period can be neglected, because

Page 310: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 17

of property (c) and the preceding discussion. Different periods are independent,by property (b). Furthermore, each period has one arrival with probabilityapproximately equal to λδ, or zero arrivals with probability approximately equalto 1 − λδ. Therefore, the process being studied can be approximated by aBernoulli process, with the approximation becoming more and more accuratethe smaller δ is chosen. Thus the probability P (k, τ) of k arrivals in time τ , isapproximately the same as the (binomial) probability of k successes in n = τ/δindependent Bernoulli trials with success probability p = λδ at each trial. Whilekeeping the length τ of the interval fixed, we let the period length δ decreaseto zero. We then note that the number n of periods goes to infinity, while theproduct np remains constant and equal to λτ . Under these circumstances, wesaw in the previous section that the binomial PMF converges to a Poisson PMFwith parameter λτ . We are then led to the important conclusion that

P (k, τ) =(λτ )ke−λτ

k!, k = 0, 1, . . . .

Note that a Taylor series expansion of e−λτ , yields

P (0, τ) = e−λτ = 1− λτ + O(τ2)

P (1, τ) = λτe−λτ = λτ − λ2τ2 + O(τ3) = λτ + O(τ2),

consistent with property (c).Using our earlier formulas for the mean and variance of the Poisson PMF,

we obtain

E[Nτ ] = λτ, var(Nτ ) = λτ,

where Nτ stands for the number of arrivals during a time interval of length τ .These formulas are hardly surprising, since we are dealing with the limit of abinomial PMF with parameters n = τ/δ, p = λδ, mean np = λτ , and variancenp(1− p) ≈ np = λτ .

Let us now derive the probability law for the time T of the first arrival,assuming that the process starts at time zero. Note that we have T > t if andonly if there are no arrivals during the interval [0, t]. Therefore,

FT (t) = P(T ≤ t) = 1−P(T > t) = 1− P (0, t) = 1− e−λt, t ≥ 0.

We then differentiate the CDF FT (t) of T , and obtain the PDF formula

fT (t) = λe−λt, t ≥ 0,

which shows that the time until the first arrival is exponentially distributed withparameter λ. We summarize this discussion in the table that follows. See alsoFig. 5.6.

Page 311: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

18 Stochastic Processes Chap. 5

Random Variables Associated with the Poisson Process and theirProperties

• The Poisson with parameter λτ . This is the number Nτ of arrivalsin a Poisson process with rate λ, over an interval of length τ . Its PMF,mean, and variance are

pNτ (k) = P (k, τ) =(λτ)ke−λτ

k!, k = 0, 1, . . . .

E[Nτ ] = λτ, var(Nτ ) = λτ.

• The exponential with parameter λ. This is the time T until thefirst arrival. Its PDF, mean, and variance are

fT (t) = λe−λt, t ≥ 0, E[T ] =1

λ, var(T ) =

1

λ2.

Time0x x x

δ

Arrivals

p =λδδ δδ δ δ δ δ

POISSON BERNOULLI

Times of Arrival Continuous Discrete

PMF of # of Arrivals Poisson Binomial

Interarrival Time CDF Exponential Geometric

Arrival Rate λ/unit time p/per trial

Figure 5.6: View of the Bernoulli process as the discrete-time version of thePoisson. We discretize time in small intervals δ and associate each interval witha Bernoulli trial whose parameter is p = λδ. The table summarizes some of thebasic correspondences.

Page 312: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 19

Example 5.7. You get email according to a Poisson process at a rate of λ = 0.2messages per hour. You check your email every hour. What is the probability offinding 0 and 1 new messages?

These probabilities can be found using the Poisson PMF (λτ )ke−λτ /k!, withτ = 1, and k = 0 or k = 1:

P(0, 1) = e−0.2 = 0.819, P(1, 1) = 0.2 · e−0.2 = 0.164

Suppose that you have not checked your email for a whole day. What is theprobability of finding no new messages? We use again the Poisson PMF and obtain

P(0, 24) = e−0.2·24 = 0.008294.

Alternatively, we can argue that the event of no messages in a 24-hour period isthe intersection of the events of no messages during each of 24 hours. These latterevents are independent and the probability of each is P(0, 1) = e−0.2, so

P(0, 24) =(P(0, 1)

)24=

(e−0.2

)24= 0.008294,

which is consistent with the preceding calculation method.

Example 5.8. Sum of Independent Poisson Random Variables. Arrivalsof customers at the local supermarket are modeled by a Poisson process with arate of λ = 10 customers per minute. Let M be the number of customers arrivingbetween 9:00 and 9:10. Also, let N be the number of customers arriving between9:30 and 9:35. What is the distribution of M + N?

We notice that M is Poisson with parameter µ = 10·10 = 100 and N is Poissonwith parameter ν = 10 ·5 = 50. Furthermore, M and N are independent. As shownin Section 4.1, using transforms, M +N is Poisson with parameter µ+ν = 150. Wewill now proceed to derive the same result in a more direct and intuitive manner.

Let N be the number of customers that arrive between 9:10 and 9:15. Notethat N has the same distribution as N (Poisson with parameter 50). Furthermore,N is also independent of N . Thus, the distribution of M + N is the same as thedistribution of M + N . But M + N is the number of arrivals during an interval oflength 15, and has therefore a Poisson distribution with parameter 10 · 15 = 150.

This example makes a point that is valid in general. The probability of karrivals during a set of times of total length τ is always given by P (k, τ), even ifthat set is not an interval. (In this example, we dealt with the set [9 : 00, 9 : 10]∪ [9 :30, 9 : 35], of total length 15.)

Example 5.9. During rush hour, from 8 am to 9 am, traffic accidents occuraccording to a Poisson process with a rate µ of 5 accidents per hour. Between 9am and 11 am, they occur as an independent Poisson process with a rate ν of 3accidents per hour. What is the PMF of the total number of accidents between 8am and 11 am?

Page 313: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

20 Stochastic Processes Chap. 5

This is the sum of two independent Poisson random variables with parameters5 and 3·2 = 6, respectively. Since the sum of independent Poisson random variablesis also Poisson, the total number of accidents has a Poisson PMF with parameter5+6=11.

Independence and Memorylessness

The Poisson process has several properties that parallel those of the Bernoulliprocess, including the independence of nonoverlapping time sets, a fresh-startproperty, and the memorylessness of the interarrival time distribution. Giventhat the Poisson process can be viewed as a limiting case of a Bernoulli process,the fact that it inherits the qualitative properties of the latter should be hardlysurprising.

(a) Independence of nonoverlapping sets of times. Consider two disjointsets of times A and B, such as A = [0,1] ∪ [4,∞) and B = [1.5, 3.6], forexample. If U and V are random variables that are completely determinedby what happens during A (respectively, B), then U and V are indepen-dent. This is a consequence of the second defining property of the Poissonprocess.

(b) Fresh-start property. As a special case of the preceding observation, wenotice that the history of the process until a particular time t is independentfrom the future of the process. Furthermore, if we focus on that portionof the Poisson process that starts at time t, we observe that it inherits thedefining properties of the original process. For this reason, the portion ofthe Poisson process that starts at any particular time t > 0 is a probabilisticreplica of the Poisson process starting at time 0, and is independent of theportion of the process prior to time t. Thus, we can say that the Poissonprocess starts afresh at each time instant.

(c) Memoryless interarrival time distribution. We have already seen thatthe geometric PMF (interarrival time in the Bernoulli process) is memo-ryless: the number of remaining trials until the first future arrival doesnot depend on the past. The exponential PDF (interarrival time in thePoisson process) has a similar property: given the current time t and thepast history, the future is a fresh-starting Poisson process, hence the re-maining time until the next arrival has the same exponential distribution.In particular, if T is the time of the first arrival and if we are told thatT > t, then the remaining time T − t is exponentially distributed, with thesame parameter λ. For an algebraic derivation of this latter fact, we firstuse the exponential CDF to obtain P(T > t) = e−λt. We then note that

Page 314: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 21

for all positive scalars s and t, we have

P(T > t + s |T > t) =P(T > t + s, T > t)

P(T > t)

=P(T > t + s)

P(T > t)

=e−λ(t+s)

e−λt

= e−λs.

Here are some examples of reasoning based on the memoryless property.

Example 5.10. You and your partner go to a tennis court, and have to wait untilthe players occupying the court finish playing. Assume (somewhat unrealistically)that their playing time has an exponential PDF. Then the PDF of your waitingtime (equivalently, their remaining playing time) also has the same exponentialPDF, regardless of when they started playing.

Example 5.11. When you enter the bank, you find that all three tellers are busyserving other customers, and there are no other customers in queue. Assume thatthe service times for you and for each of the customers being served are independentidentically distributed exponential random variables. What is the probability thatyou will be the last to leave?

The answer is 1/3. To see this, focus at the moment when you start servicewith one of the tellers. Then, the remaining time of each of the other two customersbeing served, as well as your own remaining time, have the same PDF. Therefore,you and the other two customers have equal probability 1/3 of being the last toleave.

Interarrival Times

An important random variable associated with a Poisson process that starts attime 0, is the time of the kth arrival, which we denote by Yk. A related randomvariable is the kth interarrival time, denoted by Tk. It is defined by

T1 = Y1, Tk = Yk − Yk−1, k = 2, 3, . . .

and represents the amount of time between the k−1st and the kth arrival. Notethat

Yk = T1 + T2 + · · ·+ Tk.

We have already seen that the time T1 until the first arrival is an exponen-tial random variable with parameter λ. Starting from the time T1 of the first

Page 315: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

22 Stochastic Processes Chap. 5

arrival, the future is a fresh-starting Poisson process. Thus, the time until thenext arrival has the same exponential PDF. Furthermore, the past of the process(up to time T1) is independent of the future (after time T1). Since T2 is deter-mined exclusively by what happens in the future, we see that T2 is independentof T1. Continuing similarly, we conclude that the random variables T1, T2, T3, . . .are independent and all have the same exponential distribution.

This important observation leads to an alternative, but equivalent, way ofdescribing the Poisson process.†

Alternative Description of the Poisson Process

1. Start with a sequence of independent exponential random variablesT1, T2,. . ., with common parameter λ, and let these stand for the in-terarrival times.

2. Record an arrival at times T1, T1 + T2, T1 + T2 + T3, etc.

The kth Arrival Time

The time Yk of the kth arrival is equal to the sum Yk = T1 + T2 + · · · + Tk ofk independent identically distributed exponential random variables. This allowsus to derive formulas for the mean, variance, and PMF of Yk, which are given inthe table that follows.

Properties of the kth Arrival Time

• The kth arrival time is equal to the sum of the first k interarrival times

Yk = T1 + T2 + · · ·+ Tk,

and the latter are independent exponential random variables with com-mon parameter λ.

† In our original definition, a process was called Poisson if it possessed certainproperties. However, the astute reader may have noticed that we have not so farestablished that there exists a process with the required properties. In an alternativeline of development, we could have defined the Poisson process by the alternativedescription given here, and such a process is clearly well-defined: we start with asequence of independent interarrival times, from which the arrival times are completelydetermined. Starting with this definition, it is then possible to establish that theprocess satisfies all of the properties that were postulated in our original definition.

Page 316: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 23

• The mean and variance of Yk are given by

E[Yk] = E[T1] + · · ·+ E[Tk] =k

λ,

var(Yk) = var(T1) + · · ·+ var(Tk) =k

λ2.

• The PDF of Yk is given by

fYk(y) =

λkyk−1e−λy

(k − 1)!

and is known as the Erlang PDF of order k.

To evaluate the PDF fYkof Yk, we can argue that for a small δ, the product

δ ·fYk(y) is the probability that the kth arrival occurs between times y and y+δ.†

When δ is very small, the probability of more than one arrival during the interval[y, y + δ] is negligible. Thus, the kth arrival occurs between y and y + δ if andonly if the following two events A and B occur:

(a) event A: there is an arrival during the interval [y, y + δ];

(b) event B: there are exactly k − 1 arrivals before time y.

The probabilities of these two events are

P(A) ≈ λδ, and P(B) = P (k − 1, y) =λk−1yk−1e−λy

(k − 1)!.

† For an alternative derivation that does not rely on approximation arguments,note that for a given y ≥ 0, the event

Yk ≤ y

is the same as the event

number of arrivals in the interval [0, y] ≥ k.

Thus the CDF of Yk is given by

FYk(y) = P(Yk ≤ y

)=

∞∑

n=k

P (n, y) = 1−k−1∑

n=0

P (n, y) = 1−k−1∑

n=0

(λy)ne−λy

n!.

The PDF of Yk can be obtained by differentiating the above expression, which bystraightforward calculation yields the Erlang PDF formula

fYk(y) =

d

dyFYk

(y) =λkyk−1e−λy

(k − 1)!.

Page 317: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

24 Stochastic Processes Chap. 5

Since A and B are independent, we have

δfYk (y) ≈ P(y ≤ Yk ≤ y + δ) ≈ P(A ∩B) = P(A)P(B) ≈ λδλk−1yk−1e−λy

(k − 1)!,

from which we obtain

fYk(y) =λkyk−1e−λy

(k − 1)!, y ≥ 0.

Example 5.12. You call the IRS hotline and you are told that you are the56th person in line, excluding the person currently being served. Callers departaccording to a Poisson process with a rate of λ = 2 per minute. How long will youhave to wait on the average until your service starts, and what is the probabilityyou will have to wait for more than an hour?

By the memoryless property, the remaining service time of the person cur-rently being served is exponentially distributed with parameter 2. The service timesof the 55 persons ahead of you are also exponential with the same parameter, andall of these random variables are independent. Thus, your waiting time Y is Erlangof order 56, and

E[Y ] =56

λ= 28.

The probability that you have to wait for more than an hour is given by the formula

P(Y ≥ 60) =

∫ ∞

60

λ56y55e−λy

55!dy.

Computing this probability is quite tedious. In Chapter 7, we will discuss a mucheasier way to compute approximately this probability. This is done using the centrallimit theorem, which allows us to approximate the CDF of the sum of a large numberof random variables with a normal CDF and then to calculate various probabilitiesof interest by using the normal tables.

Splitting and Merging of Poisson Processes

Similar to the case of a Bernoulli process, we can start with a Poisson processwith rate λ and split it, as follows: each arrival is kept with probability p anddiscarded with probability 1−p, independently of what happens to other arrivals.In the Bernoulli case, we saw that the result of the splitting was also a Bernoulliprocess. In the present context, the result of the splitting turns out to be aPoisson process with rate λp.

Alternatively, we can start with two independent Poisson processes, withrates λ1 and λ2, and merge them by recording an arrival whenever an arrivaloccurs in either process. It turns out that the merged process is also Poisson

Page 318: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 25

with rate λ1 + λ2. Furthermore, any particular arrival of the merged processhas probability λ1/(λ1 +λ2) of originating from the first process and probabilityλ2/(λ1 + λ2) of originating from the second, independently of all other arrivalsand their origins.

We discuss these properties in the context of some examples, and at thesame time provide a few different arguments to establish their validity.

Example 5.13. Splitting of Poisson Processes. A packet that arrives at anode of a data network is either a local packet which is destined for that node (thishappens with probability p), or else it is a transit packet that must be relayed toanother node (this happens with probability 1 − p). Packets arrive according to aPoisson process with rate λ, and each one is a local or transit packet independentlyof other packets and of the arrival times. As stated above, the process of localpacket arrivals is Poisson with rate λp. Let us see why.

We verify that the process of local packet arrivals satisfies the defining prop-erties of a Poisson process. Since λ and p are constant (do not change with time),the first property (time homogeneity) clearly holds. Furthermore, there is no de-pendence between what happens in disjoint time intervals, verifying the secondproperty. Finally, if we focus on an interval of small length δ, the probability ofa local arrival is approximately the probability that there is a packet arrival, andthat this turns out to be a local one, i.e., λδ · p. In addition, the probability oftwo or more local arrivals is negligible in comparison to δ, and this verifies thethird property. We conclude that local packet arrivals form a Poisson process and,in particular, the number Lτ of such arrivals during an interval of length τ has aPoisson PMF with parameter pλτ .

Let us now rederive the Poisson PMF of Lτ using transforms. The totalnumber of packets Nτ during an interval of length τ is Poisson with parameter λτ .For i = 1, . . . , Nτ , let Xi be a Bernoulli random variable which is 1 if the ith packetis local, and 0 if not. Then, the random variables X1, X2, . . . form a Bernoulliprocess with success probability p. The number of local packets is the number of“successes,” i.e.,

Lτ = X1 + · · · + XNτ .

We are dealing here with the sum of a random number of independent randomvariables. As discussed in Section 4.4, the transform associated with Lτ is foundby starting with the transform associated with Nτ , which is

MNτ (s) = eλτ(es−1),

and replacing each occurrence of es by the transform associated with Xi, which is

MX(s) = 1 − p + pes.

We obtainMLτ (s) = e

λτ(1−p+pes−1)= e

λτp(es−1).

We observe that this is the transform of a Poisson random variable with parameterλτp, thus verifying our earlier statement for the PMF of Lτ .

Page 319: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

26 Stochastic Processes Chap. 5

We conclude with yet another method for establishing that the local packetprocess is Poisson. Let T1, T2, . . . be the interarrival times of packets of any type;these are independent exponential random variables with parameter λ. Let K bethe total number of arrivals up to and including the first local packet arrival. Inparticular, the time S of the first local packet arrival is given by

S = T1 + T2 + · · · + TK .

Since each packet is a local one with probability p, independently of the others, andby viewing each packet as a trial which is successful with probability p, we recognizeK as a geometric random variable with parameter p. Since the nature of the packetsis independent of the arrival times, K is independent from the interarrival times. Weare therefore dealing with a sum of a random (geometrically distributed) number ofexponential random variables. We have seen in Chapter 4 (cf. Example 4.21) thatsuch a sum is exponentially distributed with parameter λp. Since the interarrivaltimes between successive local packets are clearly independent, it follows that thelocal packet arrival process is Poisson with rate λp.

Example 5.14. Merging of Poisson Processes. People with letters to mailarrive at the post office according to a Poisson process with rate λ1, while peoplewith packages to mail arrive according to an independent Poisson process with rateλ2. As stated earlier the merged process, which includes arrivals of both types, isPoisson with rate λ1 + λ2. Let us see why.

First, it should be clear that the merged process satisfies the time-homogeneityproperty. Furthermore, since different intervals in each of the two arrival processesare independent, the same property holds for the merged process. Let us now focuson a small interval of length δ. Ignoring terms that are negligible compared to δ,we have

P(0 arrivals in the merged process) ≈ (1− λ1δ)(1− λ2δ) ≈ 1 − (λ1 + λ2)δ,

P(1 arrival in the merged process) ≈ λ1δ(1− λ2δ) + (1− λ1δ)λ2δ ≈ (λ1 + λ2)δ,

and the third property has been verified.Given that an arrival has just been recorded, what is the probability that it

is an arrival of a person with a letter to mail? We focus again on a small intervalof length δ around the current time, and we seek the probability

P(1 arrival of person with a letter | 1 arrival).

Using the definition of conditional probabilities, and ignoring the negligible proba-bility of more than one arrival, this is

P(1 arrival of person with a letter)

P(1 arrival)≈ λ1δ

(λ1 + λ2)δ=

λ1

λ1 + λ2.

Example 5.15. Competing Exponentials. Two light bulbs have independentand exponentially distributed lifetimes T (1) and T (2), with parameters λ1 and λ2,

Page 320: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 27

respectively. What is the distribution of the first time Z = minT (1), T (2) at whicha bulb burns out?

We can treat this as an exercise in derived distributions. For all z ≥ 0, wehave,

FZ(z) = P(minT (1)

, T(2) ≤ z

)

= 1−P(minT (1)

, T(2) > z

)

= 1−P(T(1)

> z, T(2)

> z)

= 1−P(T (1) > z)P(T (2) > z)

= 1− e−λ1ze−λ2z

= 1− e−(λ1+λ2)z

.

This is recognized as the exponential CDF with parameter λ1 +λ2. Thus, the mini-mum of two independent exponentials with parameters λ1 and λ2 is an exponentialwith parameter λ1 + λ2.

For a more intuitive explanation of this fact, let us think of T (1) (respectively,T (2)) as the times of the first arrival in two independent Poisson process with rateλ1 (respectively, T (2)). If we merge these two Poisson processes, the first arrivaltime will be minT (1), T (2). But we already know that the merged process isPoisson with rate λ1 +λ2, and it follows that the first arrival time, minT (1), T (2),is exponential with parameter λ1 + λ2.

The preceding discussion can be generalized to the case of more than twoprocesses. Thus, the total arrival process obtained by merging the arrivals ofn independent Poisson processes with arrival rates λ1, . . . , λn is Poisson witharrival rate equal to the sum λ1 + · · ·+ λn.

Example 5.16. More on Competing Exponentials. Three light bulbs haveindependent exponentially distributed lifetimes with a common parameter λ. Whatis the expectation of the time until the last bulb burns out?

We think of the times when each bulb burns out as the first arrival timesin independent Poisson processes. In the beginning, we have three bulbs, and themerged process has rate 3λ. Thus, the time T1 of the first burnout is exponentialwith parameter 3λ, and mean 1/3λ. Once a bulb burns out, and because of thememorylessness property of the exponential distribution, the remaining lifetimesof the other two lightbulbs are again independent exponential random variableswith parameter λ. We thus have two Poisson processes running in parallel, andthe remaining time T2 until the first arrival in one of these two processes is nowexponential with parameter 2λ and mean 1/2λ. Finally, once a second bulb burnsout, we are left with a single one. Using memorylessness once more, the remainingtime T3 until the last bulb burns out is exponential with parameter λ and mean1/λ. Thus, the expectation of the total time is

E[T1 + T2 + T3] =1

3λ+

1

2λ+

1

λ.

Page 321: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

28 Stochastic Processes Chap. 5

Note that the random variables T1, T2, T3 are independent, because of memoryless-ness. This also allows us to compute the variance of the total time:

var(T1 + T2 + T3) = var(T1) + var(T2) + var(T3) =1

9λ2+

1

4λ2+

1

λ2.

We close by noting a related and quite deep fact, namely that the sumof a large number of (not necessarily Poisson) independent arrival processes,can be approximated by a Poisson process with arrival rate equal to the sum ofthe individual arrival rates. The component processes must have a small raterelative to the total (so that none of them imposes its probabilistic character onthe total arrival process) and they must also satisfy some technical mathematicalassumptions. Further discussion of this fact is beyond our scope, but we notethat it is in large measure responsible for the abundance of Poisson-like processesin practice. For example, the telephone traffic originating in a city consists ofmany component processes, each of which characterizes the phone calls placed byindividual residents. The component processes need not be Poisson; some peoplefor example tend to make calls in batches, and (usually) while in the process oftalking, cannot initiate or receive a second call. However, the total telephonetraffic is well-modeled by a Poisson process. For the same reasons, the processof auto accidents in a city, customer arrivals at a store, particle emissions fromradioactive material, etc., tend to have the character of the Poisson process.

The Random Incidence Paradox

The arrivals of a Poisson process partition the time axis into a sequence ofinterarrival intervals; each interarrival interval starts with an arrival and ends atthe time of the next arrival. We have seen that the lengths of these interarrivalintervals are independent exponential random variables with parameter λ andmean 1/λ, where λ is the rate of the process. More precisely, for every k, thelength of the kth interarrival interval has this exponential distribution. In thissubsection, we look at these interarrival intervals from a different perspective.

Let us fix a time instant t∗ and consider the length L of the interarrivalinterval to which it belongs. For a concrete context, think of a person who showsup at the bus station at some arbitrary time t∗ and measures the time from theprevious bus arrival until the next bus arrival. The arrival of this person is oftenreferred to as a “random incidence,” but the reader should be aware that theterm is misleading: t∗ is just a particular time instance, not a random variable.

We assume that t∗ is much larger than the starting time of the Poissonprocess so that we can be fairly certain that there has been an arrival priorto time t∗. To avoid the issue of determining how large a t∗ is large enough,we can actually assume that the Poisson process has been running forever, sothat we can be fully certain that there has been a prior arrival, and that L iswell-defined. One might superficially argue that L is the length of a “typical”interarrival interval, and is exponentially distributed, but this turns out to befalse. Instead, we will establish that L has an Erlang PDF of order two.

Page 322: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 29

This is known as the random incidence phenomenon or paradox, and it canbe explained with the help of Fig. 5.7. Let [U, V ] be the interarrival interval towhich t∗ belongs, so that L = V − U . In particular, U is the time of the firstarrival prior to t∗ and V is the time of the first arrival after t∗. We split L intotwo parts,

L = (t∗ − U ) + (V − t∗),

where t∗−U is the elapsed time since the last arrival, and V −t∗ is the remainingtime until the next arrival. Note that t∗−U is determined by the past history ofthe process (before t∗), while V − t∗ is determined by the future of the process(after time t∗). By the independence properties of the Poisson process, therandom variables t∗ − U and V − t∗ are independent. By the memorylessnessproperty, the Poisson process starts fresh at time t∗, and therefore V − t∗ isexponential with parameter λ. The random variable t∗ − U is also exponentialwith parameter λ. The easiest way of seeing this is to realize that if we run aPoisson process backwards in time it remains Poisson; this is because the definingproperties of a Poisson process make no reference to whether time moves forwardor backward. A more formal argument is obtained by noting that

P(t∗ − U > x) = P(no arrivals during [t∗ − x, t∗]

)= P (0, x) = e−λx, x ≥ 0.

We have therefore established that L is the sum of two independent exponentialrandom variables with parameter λ, i.e., Erlang of order two, with mean 2/λ.

x xTime

Chosen time instant

Remaining

time V−t* Elapsed

time t*−U

t*

L

U V

Figure 5.7: Illustration of the random incidence phenomenon. For a fixed timeinstant t∗, the corresponding interarrival interval [U, V ] consists of the elapsedtime t∗ − U and the remaining time V − t∗. These two times are independentand are exponentially distributed with parameter λ, so the PDF of their sum isErlang of order two.

Random incidence phenomena are often the source of misconceptions anderrors, but these can be avoided with careful probabilistic modeling. The keyissue is that even though interarrival intervals have length 1/λ on the average, anobserver who arrives at an arbitrary time is more likely to fall in a large ratherthan a small interarrival interval. As a consequence the expected length seen bythe observer is higher, 2/λ in this case. This point is amplified by the examplethat follows.

Page 323: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

30 Stochastic Processes Chap. 5

Example 5.17. Random incidence in a non-Poisson arrival process. Busesarrive at a station deterministically, on the hour, and fifteen minutes after the hour.Thus, the interarrival times alternate between 15 and 45 minutes. The averageinterarrival time is 30 minutes. A person shows up at the bus station at a “random”time. We interpret “random” to mean a time which is uniformly distributed withina particular hour. Such a person falls into an interarrival interval of length 15 withprobability 1/4, and an interarrival interval of length 45 with probability 3/4. Theexpected value of the length of the chosen interarrival interval is

15 · 1

4+ 45 · 3

4= 37.5,

which is considerably larger than 30, the average interarrival time.

Page 324: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 31

S O L V E D P R O B L E M S

SECTION 5.1. The Bernoulli Process

Problem 1. Dave fails quizzes with probability 1/4, independently of other quizzes.

(a) What is the probability that that Dave fails exactly two of the next six quizzes?

(b) What is the expected number of quizzes that Dave will pass before he has failedthree times?

(c) What is the probability that the second and third time Dave fails a quiz willoccur when he takes his eighth and ninth quizzes, respectively?

(d) What is the probability that Dave fails two quizzes in a row before he passes twoquizzes in a row?

Solution. (a) We have a Bernoulli process with parameter p = 1/4. The desired prob-ability is given by the binomial formula:

(6

2

)p2(1− p)4 =

(6

2

) (1

4

)2 (3

4

)4

.

(b) The expected number of quizzes up to the third failure is the expected value of thethird order Pascal with parameter 1/4, which is 3 · 4 = 12. Subtracting the number offailures, we have that the expected number of quizzes that Dave will pass is 12−3 = 9.

(c) The event whose probability we want to find is the intersection of the followingthree independent events:

A: There is exactly one failure in the first seven quizzes.

B: Quiz eight is a failure.

C: Quiz nine is a failure.

We have

P(A) =

(7

1

) (1

4

)(3

4

)6

, P(B) = P(C) =1

4,

so the desired probability is

P(A ∩ B ∩ C) = 7(

1

4

)3 (3

4

)6

.

(d)

Problem 2. Each of n packages is loaded independently into either a red truck (withprobability P ) or into a green truck (with probability 1−P ). Let R be the total number

Page 325: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

32 Stochastic Processes Chap. 5

of items selected for the red truck and let G be the total number of items selected forthe green truck.

(a) Determine the PMF, expected value, and variance for random variable R.

(b) Evaluate P(A), the probability that the first item to be loaded ends up being theonly one on its truck.

(c) Evaluate P(B), the probability that at least one truck ends up with a total ofexactly one package.

(d) Evaluate the expectation and the variance for the difference, D = R−G.

(e) Assume n ≥ 2. Given that both of the first two packages to be loaded go ontothe red truck, find the conditional expectation, variance and probability law forrandom variable R.

Solution. (a) R is a binomial random variable with parameters p and N , hence

pR(r) =

(n

r

)(1− p)

n−rp

rfor r = 0, 1, 2, . . . , n.

Note that R can be written as a sum of n i.i.d. Bernoulli random variables, R =X1 + X2 + · · · + Xn, where Xi = 1 if the ith package is loaded onto the red truck andXi = 0 otherwise. It is easy to verify that E[X] = p and var(X) = p(1− p), thus

E[R] = E[X1 + · · ·+ Xn] = E[X1] + E[X2] + · · ·+ E[Xn] = np,

andvar(R) = var(X1) + · · · + var(Xn) = np(1− p).

(b) The event A is the union of two disjoint events:

1. the first item is placed in the red truck and the remaining n−1 are placed in thegreen truck, and

2. the first item is placed in the green truck and the remaining n − 1 are placed inthe red truck.

Thus, P(A) = p(1− p)n−1 + (1− p)pn−1.

(c) The event B occurs if exactly one or both of the trucks end up with exactly 1package, so

P(B) =

1 if n = 12p(1− p) if n = 2(

n1

)(1− p)n−1p +

(n

n−1

)pn−1(1− p) if n = 3, 4, 5, . . .

(d) E[D] = E[R − G] = E[R − (n − R)] = E[2R − n] = 2E[R] − n = 2np − n. SinceD = 2R− n, where n is a constant,

var(D) = 4var(R) = 4np(1− p).

(e) Let C be the event that each of the first 2 packages is loaded onto the red truck;then the random variable R given C becomes

2 + X3 + X4 + · · · + Xn.

Page 326: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 33

Hence,

E[R |C] = E[2 + X3 + X4 + · · ·+ Xn] = 2 + (n− 2)E[X] = 2 + (n− 2)p.

Similarly the conditional variance of R is:

var(R |C) = var(2 + X3 + X4 + · · · + Xn) = (n − 2)var(Xi) = (n− 2)p(1− p).

Finally, given that the first two packages go to the red truck, the probability that atotal of r packages are loaded onto the red truck is equal to the probability that r − 2of the remaining n − 2 packages go to the red truck:

pR |C(r |C) =

(n − 2

r− 2

)(1− p)(n−r)p(r−2) for r = 2, . . . , n.

Problem 3. * Consider the Bernoulli process with probability of success in each trialequal to p.

(a) Obtain a simple expression for the probability that the ith success occurs beforethe jth failure.

(b) Find the expected value and variance of the number of successes which occurbefore the jth failure.

Solution. (a) Let Si and Fj be the times of the ith success and jth failure, respectively.The event Si < Fj is the same as the event of having greater or equal to i successesin the first i + j − 1 trials. Thus, we have

P(Si < Fj) =

i+j−1∑

k=i

pk(1− p)i+j−1−k.

(b) Let k be the number of successes that occur before the jth failure. We have

E[k] =pj

1 − p,

var(k) =pj

(1− p)2.

Problem 4. * The PMF for the number of failures before the rth success in a Bernoulliprocess is sometimes called the negative binomial PMF. Relate the correspondingrandom variable to a Pascal random variable, and derive its PMF.

Solution. If X is the negative binomial random variable and Y is the Pascal randomvariable of order r, we have X = Y − r. Therefore pX(x) = pY (x + r), so that

pX(x) =

(x + r − 1

r − 1

)pr(1− p)x.

Page 327: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

34 Stochastic Processes Chap. 5

Problem 5. * Random incidence in the Bernoulli process. A hotel receptionistwith a passion for flipping a special coin that comes up a head with probability p isengaged in her favorite pastime. She flips her coin sequentially and independently,and does not raise her head to acknowledge a waiting customer until a head comes up.Suppose that a customer arrives as she flips a tail. What is the PMF of the length of thestring of tails that starts with the tail following the first head prior to the customer’sarrival and ends at the time she will acknowledge the customer.

Solution. Let T be the arrival time of the customer, let M be the time of the lasthead flip prior to T , and let N be the time of the first head flip after T . The randomvariable X = N − T is geometrically distributed with parameter p. By symmetryand independence of the flips, the random variable Y = T −M is also geometricallydistributed with parameter p. The length of the string of tails between M and N is

L = N −M − 1 = X + Y − 1.

Thus L + 1 has a Pascal PMF of order two, and

pL(l) =

(l

1

)p2(1− p)l−1, l = 1, 2, . . .

SECTION 5.2. The Poisson Process

Problem 6. A wombat in the San Diego zoo spends the day walking from a burrowto a food tray, eating, walking back to the burrow, resting, and repeating the cycle.The amount of time to walk from the burrow to the tray (and also from the tray to theburrow) is 20 secs. The amounts of time spent at the tray and resting are exponentiallydistributed with mean 30 secs. The wombat, with probability 1/3, will momentarilystand still (for a negligibly small time) during a walk to or from the tray, with all timesbeing equally likely (and independently of what happened in the past). A photographerarrives at a random time and will take a picture at the first time the wombat will standstill. What is the expected value of the length of time the photographer has to wait tosnap the wombat’s picture?

Solution. We will calculate the expected length of the photographer’s waiting time Tconditioned on each of the two events: A, which is that the photographer arrives whilethe wombat is resting or eating, and Ac, which is that the photographer arrives whilethe wombat is walking. We will then use the total expectation theorem as follows:

E[T ] = P(A)E[T |A] + P(Ac)E[T |Ac].

The conditional expectation E[T |A] can be broken down in three components:

(1) The expected remaining time up to when the wombat starts its next walk; bythe memoryless property, this time is exponentially distributed and its expectedvalue is 30 secs.

(2) A number of walking and resting/eating intervals (each of expected length 50 secs)during which the wombat does not stop; if N is the number of these intervals,

Page 328: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 5.2 The Poisson Process 35

then N + 1 is geometrically distributed with parameter 1/3. Thus the expectedlength of these intervals is (3− 1) · 50 = 100 secs.

(3) The expected waiting time during the walking interval when the wombat standsstill. This time is uniformly distributed between 0 and 20, so its expected valueis 10 secs.

Collecting the above terms, we see that

E[T |A] = 30 + 100 + 10 = 140.

The conditional expectation E[T |Ac] can be calculated using the total expecta-tion theorem, by conditioning on three events: B1, which is that the wombat does notstop during the photographer’s arrival interval (probability 2/3); B2, which is that thewombat stops during the photographer’s arrival interval after the photographer arrives(probability 1/6); B3, which is that the wombat stops during the photographer’s arrivalinterval before the photographer arrives (probability 1/6). We have

E[T |Ac, B1] = E[photographer’s wait up to the end of the interval] + E[T |A]

= 10 + 140 = 150.

Also, it can be shown that if two points are randomly chosen in an interval of lengthl, the expected distance between the two points is l/3 (an end-of-chapter problem inChapter 3), and using this fact, we have

E[T |Ac, B2] = E[photographer’s wait up to the time when the wombat stops] =20

3.

Similarly, it can be shown that if two points are randomly chosen in an interval oflength l, the expected distance between each point and the nearest endpoint of theinterval is l/3. Using this fact, we have

E[T |Ac, B3] = E[photographer’s wait up to the end of the interval] + E[T |A]

=20

3+ 140.

Applying the total expectation theorem, we see that

E[T |Ac] =2

3150 +

1

6

20

3+

1

6

(20

3+ 140

)= 125.55.

To apply the total expectation theorem for obtaining E[T ], we need the proba-bility

P(A) =

∫ ∞

0

x

20 + x

1

30e−x/30 dx,

which must be calculated numerically. Once this is done all the quantities needed inthe formula

E[T ] = P(A)E[T |A] +(1 −P(A)

)E[T |Ac]

will have been calculated.

Page 329: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

36 Stochastic Processes Chap. 5

Problem 7. * Show that in the Poisson process, given that a single arrival occurredin a given interval [a, b], the PDF of the time of arrival is uniform over [a, b].

Problem 8. * Show that when a Poisson process is split into two Poisson processesby randomization, the two processes are independent.

Problem 9. * Let Yk be the time of the kth arrival in a Poisson process with rateλ. Show that for all y > 0,

∞∑

k=1

fYk(y) = λ.

Solution. We have

∞∑

k=1

fYk(y) =

∞∑

k=1

λkyk−1e−λy

(k − 1)!

= λ

∞∑

k=1

λk−1yk−1e−λy

(k − 1)!(let m = k − 1)

= λ

∞∑

m=0

λmyme−λy

m!

= λ.

The last equality holds because the λmyme−λy

m! terms are the values of a Poisson PMFwith parameter λ and must therefore sum to 1.

For a more intuitive derivation, let δ be a small positive number and consider thefollowing events:

Ak: the kth arrival occurs between y and y + δ;

A: an arrival occurs between y and y + δ.

Notice that the events A1, A2, . . . are disjoint and their union is A. Therefore,

∞∑

k=1

fYk(y) · δ ≈∞∑

k=1

P(Ak)

= P(A)

≈ λδ,

and the desired result follows by canceling δ from both sides.Problem 10. * Consider an experiment involving two independent Poisson processeswith rates λ1 and λ2. Let X1(k) and X2(k) be the time of the kth arrival in the 1stand the 2nd process, respectively. Show that

P(X1(n) < X2(m)

)=

n+m−1∑

k=n

(n + m − 1

k

) (λ1

λ1 + λ2

)k (λ2

λ1 + λ2

)n+m−1−k

.

Page 330: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

6

Markov Chains

Contents

6.1. Discrete-Time Markov Chains . . . . . . . . . . . . . . . p. 26.2. Classification of States . . . . . . . . . . . . . . . . . . . p. 96.3. Steady-State Behavior . . . . . . . . . . . . . . . . . . p. 136.4. Absorption Probabilities and Expected Time to Absorption . p. 256.5. More General Markov Chains . . . . . . . . . . . . . . . p. 33

1

Page 331: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

2 Markov Chains Chap. 6

The Bernoulli and Poisson processes studied in the preceding chapter are memo-ryless, in the sense that the future does not depend on the past: the occurrencesof new “successes” or “arrivals” do not depend on the past history of the process.In this chapter, we consider processes where the future depends on and can bepredicted to some extent by what has happened in the past.

We emphasize models where the effect of the past on the future is summa-rized by a state, which changes over time according to given probabilities. Werestrict ourselves to models whose state can take a finite number of values andcan change in discrete instants of time. We want to analyze the probabilisticproperties of the sequence of state values.

The range of applications of the models of this chapter is truly vast. Itincludes just about any dynamical system whose evolution over time involvesuncertainty, provided the state of the system is suitably defined. Such systemsarise in a broad variety of fields, such as communications, automatic control,signal processing, manufacturing, economics, resource allocation, etc.

6.1 DISCRETE-TIME MARKOV CHAINS

We will first consider discrete-time Markov chains, in which the state changesat certain discrete time instants, indexed by an integer variable n. At each timestep n, the Markov chain has a state, denoted by Xn, which belongs to a finiteset S of possible states, called the state space. Without loss of generality, andunless there is a statement to the contrary, we will assume that S = 1, . . . , m,for some positive integer m. The Markov chain is described in terms of itstransition probabilities pij : whenever the state happens to be i, there isprobability pij that the next state is equal to j. Mathematically,

pij = P(Xn+1 = j |Xn = i), i, j ∈ S.

The key assumption underlying Markov processes is that the transition proba-bilities pij apply whenever state i is visited, no matter what happened in thepast, and no matter how state i was reached. Mathematically, we assume theMarkov property, which requires that

P(Xn+1 = j |Xn = i, Xn−1 = in−1, . . . , X0 = i0) = P(Xn+1 = j |Xn = i)

= pij ,

for all times n, all states i, j ∈ S , and all possible sequences i0, . . . , in−1 of earlierstates. Thus, the probability law of the next state Xn+1 depends on the pastonly through the value of the present state Xn.

The transition probabilities pij must be of course nonnegative, and sum toone:

m∑

j=1

pij = 1, for all i.

Page 332: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.1 Discrete-Time Markov Chains 3

We will generally allow the probabilities pii to be positive, in which case it ispossible for the next state to be the same as the current one. Even though thestate does not change, we still view this as a state transition of a special type (a“self-transition”).

Specification of Markov Models

• A Markov chain model is specified by identifying(a) the set of states S = 1, . . . ,m,(b) the set of possible transitions, namely, those pairs (i, j) for which

pij > 0, and,(c) the numerical values of those pij that are positive.

• The Markov chain specified by this model is a sequence of randomvariables X0,X1, X2, . . ., that take values in S and which satisfy

P(Xn+1 = j |Xn = i,Xn−1 = in−1, . . . , X0 = i0) = pij ,

for all times n, all states i, j ∈ S, and all possible sequences i0, . . . , in−1

of earlier states.

All of the elements of a Markov chain model can be encoded in a transitionprobability matrix, which is simply a two-dimensional array whose elementat the ith row and jth column is pij :

p11 p12 · · · p1m

p21 p22 · · · p2m...

......

...pm1 pm2 · · · pmm

.

It is also helpful to lay out the model in the so-called transition probabilitygraph, whose nodes are the states and whose arcs are the possible transitions.By recording the numerical values of pij near the corresponding arcs, one canvisualize the entire model in a way that can make some of its major propertiesreadily apparent.

Example 6.1. Alice is taking a probability class and in each week she can beeither up-to-date or she may have fallen behind. If she is up-to-date in a givenweek, the probability that she will be up-to-date (or behind) in the next week is0.8 (or 0.2, respectively). If she is behind in the given week, the probability thatshe will be up-to-date (or behind) in the next week is 0.6 (or 0.4, respectively). Weassume that these probabilities do not depend on whether she was up-to-date orbehind in previous weeks, so the problem has the typical Markov chain character(the future depends on the past only through the present).

Page 333: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

4 Markov Chains Chap. 6

Let us introduce states 1 and 2, and identify them with being up-to-date andbehind, respectively. Then, the transition probabilities are

p11 = 0.8, p12 = 0.2, p21 = 0.6, p22 = 0.4,

and the transition probability matrix is

[0.8 0.20.6 0.4

].

The transition probability graph is shown in Fig. 6.1.

1 2

Up-to-Date Behind

0.8

0.2

0.4

0.6

Figure 6.1: The transition probability graph in Example 6.1.

Example 6.2. A fly moves along a straight line in unit increments. At eachtime period, it moves one unit to the left with probability 0.3, one unit to the rightwith probability 0.3, and stays in place with probability 0.4, independently of thepast history of movements. A spider is lurking at positions 1 and m: if the flylands there, it is captured by the spider, and the process terminates. We want toconstruct a Markov chain model, assuming that the fly starts in one of the positions2, . . . , m− 1.

Let us introduce states 1, 2, . . . , m, and identify them with the correspondingpositions of the fly. The nonzero transition probabilities are

p11 = 1, pmm = 1,

pij =

0.3 if j = i− 1 or j = i + 1,0.4 if j = i,

for i = 2, . . . ,m − 1.

The transition probability graph and matrix are shown in Fig. 6.2.

Given a Markov chain model, we can compute the probability of any partic-ular sequence of future states. This is analogous to the use of the multiplicationrule in sequential (tree) probability models. In particular, we have

P(X0 = i0, X1 = i1, . . . , Xin = in) = P(X0 = i0)pi0i1pi1i2 · · · pin−1in .

Page 334: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.1 Discrete-Time Markov Chains 5

1 20.3

1

0.4

3 4 1

0.4

0.3

0.30.3

0.3

1

0.4

pij

3

2

4

1 32 4

1.0

1.0

000

0 000

0

0.40.3

0.30.3

Figure 6.2: The transition probability graph and the transition probability ma-trix in Example 6.2, for the case where m = 4.

To verify this property, note that

P(X0 = i0, X1 = i1, . . . , Xin = in)

= P(Xn = in |X0 = i0, . . . , Xn−1 = in−1)P(X0 = i0, . . . , Xn−1 = in−1)

= pin−1inP(X0 = i0, . . . , Xn−1 = in−1),

where the last equality made use of the Markov property. We then apply thesame argument to the term P(X0 = i0, . . . ,Xn−1 = in−1) and continue similarly,until we eventually obtain the desired expression. If the initial state X0 is givenand is known to be equal to some i0, a similar argument yields

P(X1 = i1, . . . , Xin = in |X0 = i0) = pi0i1pi1i2 · · ·pin−1in .

Graphically, a state sequence can be identified with a sequence of arcs in thetransition probability graph, and the probability of such a path (given the ini-tial state) is given by the product of the probabilities associated with the arcstraversed by the path.

Example 6.3. For the spider and fly example (Example 6.2), we have

P(X1 = 2,X2 = 2,X3 = 3,X4 = 4 |X0 = 2) = p22p22p23p34 = (0.4)2(0.3)

2.

We also have

P(X0 = 2,X1 = 2,X2 = 2,X3 = 3,X4 = 4) = P(X0 = 2)p22p22p23p34

= P(X0 = 2)(0.4)2(0.3)2.

Note that in order to calculate a probability of this form, in which there is noconditioning on a fixed initial state, we need to specify a probability law for theinitial state X0.

Page 335: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

6 Markov Chains Chap. 6

n-Step Transition Probabilities

Many Markov chain problems require the calculation of the probability law ofthe state at some future time, conditioned on the current state. This probabilitylaw is captured by the n-step transition probabilities, defined by

rij(n) = P(Xn = j |X0 = i).

In words, rij(n) is the probability that the state after n time periods will be j,given that the current state is i. It can be calculated using the following basicrecursion, known as the Chapman-Kolmogorov equation.

Chapman-Kolmogorov Equation for the n-Step TransitionProbabilities

The n-step transition probabilities can be generated by the recursive formula

rij(n) =m∑

k=1

rik(n− 1)pkj , for n > 1, and all i, j,

starting withrij(1) = pij .

To verify the formula, we apply the total probability theorem as follows:

P(Xn = j |X0 = i) =

m∑

k=1

P(Xn−1 = k |X0 = i) ·P(Xn = j |Xn−1 = k, X0 = i)

=m∑

k=1

rik(n− 1)pkj ;

see Fig. 6.3 for an illustration. We have used here the Markov property: oncewe condition on Xn−1 = k, the conditioning on X0 = i does not affect theprobability pkj of reaching j at the next step.

We can view rij(n) as the element at the ith row and jth column of a two-

dimensional array, called the n-step transition probability matrix.† Figures

† Those readers familiar with matrix multiplication, may recognize that theChapman-Kolmogorov equation can be expressed as follows: the matrix of n-step tran-sition probabilities rij(n) is obtained by multiplying the matrix of (n − 1)-step tran-sition probabilities rik(n − 1), with the one-step transition probability matrix. Thus,the n-step transition probability matrix is the nth power of the transition probabilitymatrix.

Page 336: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.1 Discrete-Time Markov Chains 7

1

k

j

m

pmj

p1j

i

ri1(n-1)

rik(n-1)

rim(n-1)

pkj

Time 0 Time n-1 Time n

Figure 6.3: Derivation of the Chapman-Kolmogorov equation. The probabilityof being at state j at time n is the sum of the probabilities rik(n − 1)pkj of thedifferent ways of reaching j.

BUpD

B

UpD 0.8 0.2

0.40.6

.76 .24

.28.72

.752 .248

.256.744

.7504 .2496

.2512.7488

rij (5)

.7501 .2499

.2502.7498

rij (1) rij (2) rij (3) rij (4)

Sequence of n -step transition probability matrices

n-step transition probabilities as a function of the numbern of transitions

0

0.75

0.25

n

r11(n)

r12(n)

0

0.75

0.25

n

r22(n)r21(n)

Figure 6.4: n-step transition probabilities for the “up-to-date/behind” Example6.1. Observe that as n →∞, rij(n) converges to a limit that does not depend onthe initial state.

6.4 and 6.5 give the n-step transition probabilities rij(n) for the cases of Ex-amples 6.1 and 6.2, respectively. There are some interesting observations aboutthe limiting behavior of rij(n) in these two examples. In Fig. 6.4, we see that

Page 337: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

8 Markov Chains Chap. 6

each rij(n) converges to a limit, as n → ∞, and this limit does not depend onthe initial state. Thus, each state has a positive “steady-state” probability ofbeing occupied at times far into the future. Furthermore, the probability rij(n)depends on the initial state i when n is small, but over time this dependencediminishes. Many (but by no means all) probabilistic models that evolve overtime have such a character: after a sufficiently long time, the effect of their initialcondition becomes negligible.

In Fig. 6.5, we see a qualitatively different behavior: rij(n) again converges,but the limit depends on the initial state, and can be zero for selected states.Here, we have two states that are “absorbing,” in the sense that they are infinitelyrepeated, once reached. These are the states 1 and 4 that correspond to thecapture of the fly by one of the two spiders. Given enough time, it is certainthat some absorbing state will be reached. Accordingly, the probability of beingat the non-absorbing states 2 and 3 diminishes to zero as time increases.

1

3

2

4

1 32 4

0.3

0.4

1.0

1.0

000

0 000

0

0.40.3

0.30.3 .25

1.0

1.0

000

0 00

.09.24.42 .17

1.0

1.0

000

0 00

.16.17.50 .12

1.0

1.0

000

0 00

.21.12.55 0

1.0

1.0

000

0 00

1/302/3

rij (1) rij (2) rij (3) rij (4) rij (∞)

.09 .24 .42.25 .17.16 .17 .50 .12.21 .12 .55. . . .

01/3 0 2/3

Sequence of transition probability matrices

n-step transition probabilities as a function of the time n

0 n

r21(n)

r24(n)

2/3

1/3r22(n)

r23(n)

Figure 6.5: n-step transition probabilities for the “spiders-and-fly” Example 6.2.Observe that rij (n) converges to a limit that depends on the initial state.

These examples illustrate that there is a variety of types of states andasymptotic occupancy behavior in Markov chains. We are thus motivated toclassify and analyze the various possibilities, and this is the subject of the nextthree sections.

Page 338: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.2 Classification of States 9

6.2 CLASSIFICATION OF STATES

In the preceding section, we saw through examples several types of Markov chainstates with qualitatively different characteristics. In particular, some states, afterbeing visited once, are certain to be revisited again, while for some other statesthis may not be the case. In this section, we focus on the mechanism by whichthis occurs. In particular, we wish to classify the states of a Markov chain witha focus on the long-term frequency with which they are visited.

As a first step, we make the notion of revisiting a state precise. Let us saythat a state j is accessible from a state i if for some n, the n-step transitionprobability rij(n) is positive, i.e., if there is positive probability of reaching j,starting from i, after some number of time periods. An equivalent definition isthat there is a possible state sequence i, i1, . . . , in−1, j, that starts at i and endsat j, in which the transitions (i, i1), (i1, i2), . . . , (in−2, in−1), (in−1, j) all havepositive probability. Let A(i) be the set of states that are accessible from i. Wesay that i is recurrent if for every j that is accessible from i, i is also accessiblefrom j; that is, for all j that belong to A(i) we have that i belongs to A(j).

When we start at a recurrent state i, we can only visit states j ∈ A(i)from which i is accessible. Thus, from any future state, there is always someprobability of returning to i and, given enough time, this is certain to happen.By repeating this argument, if a recurrent state is visited once, it will be revisitedan infinite number of times.

A state is called transient if it is not recurrent. In particular, there arestates j ∈ A(i) such that i is not accessible from j. After each visit to state i,there is positive probability that the state enters such a j. Given enough time,this will happen, and state i cannot be visited after that. Thus, a transient statewill only be visited a finite number of times.

Note that transience or recurrence is determined by the arcs of the tran-sition probability graph [those pairs (i, j) for which pij > 0] and not by thenumerical values of the pij . Figure 6.6 provides an example of a transition prob-ability graph, and the corresponding recurrent and transient states.

1 2 3 4

Recurrent RecurrentRecurrentTransient

Figure 6.6: Classification of states given the transition probability graph. Start-ing from state 1, the only accessible state is itself, and so 1 is a recurrent state.States 1, 3, and 4 are accessible from 2, but 2 is not accessible from any of them,so state 2 is transient. States 3 and 4 are accessible only from each other (andthemselves), and they are both recurrent.

If i is a recurrent state, the set of states A(i) that are accessible from i

Page 339: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

10 Markov Chains Chap. 6

form a recurrent class (or simply class), meaning that states in A(i) are allaccessible from each other, and no state outside A(i) is accessible from them.Mathematically, for a recurrent state i, we have A(i) = A(j) for all j that belongto A(i), as can be seen from the definition of recurrence. For example, in thegraph of Fig. 6.6, states 3 and 4 form a class, and state 1 by itself also forms aclass.

It can be seen that at least one recurrent state must be accessible from anygiven transient state. This is intuitively evident, and a more precise justificationis given in the theoretical problems section. It follows that there must existat least one recurrent state, and hence at least one class. Thus, we reach thefollowing conclusion.

Markov Chain Decomposition

• A Markov chain can be decomposed into one or more recurrent classes,plus possibly some transient states.

• A recurrent state is accessible from all states in its class, but is notaccessible from recurrent states in other classes.

• A transient state is not accessible from any recurrent state.

• At least one, possibly more, recurrent states are accessible from a giventransient state.

Figure 6.7 provides examples of Markov chain decompositions. Decompo-sition provides a powerful conceptual tool for reasoning about Markov chainsand visualizing the evolution of their state. In particular, we see that:

(a) once the state enters (or starts in) a class of recurrent states, it stays withinthat class; since all states in the class are accessible from each other, allstates in the class will be visited an infinite number of times;

(b) if the initial state is transient, then the state trajectory contains an ini-tial portion consisting of transient states and a final portion consisting ofrecurrent states from the same class.

For the purpose of understanding long-term behavior of Markov chains, it is im-portant to analyze chains that consist of a single recurrent class. For the purposeof understanding short-term behavior, it is also important to analyze the mech-anism by which any particular class of recurrent states is entered starting from agiven transient state. These two issues, long-term and short-term behavior, arethe focus of Sections 6.3 and 6.4, respectively.

Periodicity

One more characterization of a recurrent class is of special interest, and relates

Page 340: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.2 Classification of States 11

1 2 3 4

Single class of recurrent states

1 2

3

Single class of recurrent states (1 and 2)and one transient state (3)

Two classes of recurrent states (class of state1 and class of states 4 and 5)and two transient states (2 and 3)

1 2 3 4 5

Figure 6.7: Examples of Markov chain decompositions into recurrent classes andtransient states.

to the presence or absence of a certain periodic pattern in the times that a stateis visited. In particular, a recurrent class is said to be periodic if its states canbe grouped in d > 1 disjoint subsets S1, . . . , Sd so that all transitions from onesubset lead to the next subset; see Fig. 6.8. More precisely,

if i ∈ Sk and pij > 0, then

j ∈ Sk+1, if k = 1, . . . , d− 1,j ∈ S1, if k = d.

A recurrent class that is not periodic, is said to be aperiodic.Thus, in a periodic recurrent class, we move through the sequence of subsets

in order, and after d steps, we end up in the same subset. As an example, therecurrent class in the second chain of Fig. 6.7 (states 1 and 2) is periodic, andthe same is true of the class consisting of states 4 and 5 in the third chain of Fig.6.7. All other classes in the chains of this figure are aperiodic.

Page 341: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

12 Markov Chains Chap. 6

6

1

2

3

4

5

S1

S3

S2

Figure 6.8: Structure of a periodic recurrent class.

Note that given a periodic recurrent class, a positive time n, and a state j inthe class, there must exist some state i such that rij(n) = 0. The reason is that,from the definition of periodicity, the states are grouped in subsets S1, . . . , Sd,and the subset to which j belongs can be reached at time n from the states inonly one of the subsets. Thus, a way to verify aperiodicity of a given recurrentclass R, is to check whether there is a special time n ≥ 1 and a special states ∈ R that can be reached at time n from all initial states in R, i.e., ris(n) > 0for all i ∈ R. As an example, consider the first chain in Fig. 6.7. State s = 2can be reached at time n = 2 starting from every state, so the unique recurrentclass of that chain is aperiodic.

A converse statement, which we do not prove, also turns out to be true:if a recurrent class is not periodic, then a time n and a special state s with theabove properties can always be found.

Periodicity

Consider a recurrent class R.

• The class is called periodic if its states can be grouped in d > 1disjoint subsets S1, . . . , Sd, so that all transitions from Sk lead to Sk+1

(or to S1 if k = d).

• The class is aperiodic (not periodic) if and only if there exists a timen and a state s in the class, such that pis(n) > 0 for all i ∈ R.

Page 342: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.3 Steady-State Behavior 13

6.3 STEADY-STATE BEHAVIOR

In Markov chain models, we are often interested in long-term state occupancybehavior, that is, in the n-step transition probabilities rij(n) when n is verylarge. We have seen in the example of Fig. 6.4 that the rij(n) may converge tosteady-state values that are independent of the initial state, so to what extentis this behavior typical?

If there are two or more classes of recurrent states, it is clear that thelimiting values of the rij(n) must depend on the initial state (visiting j far intothe future will depend on whether j is in the same class as the initial state i).We will, therefore, restrict attention to chains involving a single recurrent class,plus possibly some transient states. This is not as restrictive as it may seem,since we know that once the state enters a particular recurrent class, it will staywithin that class. Thus, asymptotically, the presence of all classes except for oneis immaterial.

Even for chains with a single recurrent class, the rij(n) may fail to converge.To see this, consider a recurrent class with two states, 1 and 2, such that fromstate 1 we can only go to 2, and from 2 we can only go to 1 (p12 = p21 = 1).Then, starting at some state, we will be in that same state after any even numberof transitions, and in the other state after any odd number of transitions. Whatis happening here is that the recurrent class is periodic, and for such a class, itcan be seen that the rij(n) generically oscillate.

We now assert that for every state j, the n-step transition probabilitiesrij(n) approach a limiting value that is independent of i, provided we excludethe two situations discussed above (multiple recurrent classes and/or a periodicclass). This limiting value, denoted by πj , has the interpretation

πj ≈ P(Xn = j), when n is large,

and is called the steady-state probability of j. The following is an importanttheorem. Its proof is quite complicated and is outlined together with severalother proofs in the theoretical problems section.

Steady-State Convergence Theorem

Consider a Markov chain with a single recurrent class, which is aperiodic.Then, the states j are associated with steady-state probabilities πj thathave the following properties.

(a) limn→∞

rij(n) = πj , for all i, j.

Page 343: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

14 Markov Chains Chap. 6

(b) The πj are the unique solution of the system of equations below:

πj =m∑

k=1

πkpkj, j = 1, . . . , m,

1 =

m∑

k=1

πk.

(c) We haveπj = 0, for all transient states j,

πj > 0, for all recurrent states j.

Since the steady-state probabilities πj sum to 1, they form a probabilitydistribution on the state space, called the stationary distribution of the chain.The reason for the name is that if the initial state is chosen according to thisdistribution, i.e., if

P(X0 = j) = πj , j = 1, . . . , m,

then, using the total probability theorem, we have

P(X1 = j) =

m∑

k=1

P(X0 = k)pkj =

m∑

k=1

πkpkj = πj ,

where the last equality follows from part (b) of the steady-state convergencetheorem. Similarly, we obtain P(Xn = j) = πj, for all n and j. Thus, if theinitial state is chosen according to the stationary distribution, all subsequentstates will have the same distribution.

The equations

πj =

m∑

k=1

πkpkj, j = 1, . . . , m,

are called the balance equations. They are a simple consequence of part (a)of the theorem and the Chapman-Kolmogorov equation. Indeed, once the con-vergence of rij(n) to some πj is taken for granted, we can consider the equation,

rij(n) =

m∑

k=1

rik(n− 1)pkj ,

Page 344: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.3 Steady-State Behavior 15

take the limit of both sides as n →∞, and recover the balance equations.† Thebalance equations are a linear system of equations that, together with

∑mk=1 πk =

1, can be solved to obtain the πj . The following examples illustrate the solutionprocess.

Example 6.4. Consider a two-state Markov chain with transition probabilities

p11 = 0.8, p12 = 0.2,

p21 = 0.6, p22 = 0.4.

[This is the same as the chain of Example 6.1 (cf. Fig. 6.1).] The balance equationstake the form

π1 = π1p11 + π2p21, π2 = π1p12 + π2p22,

orπ1 = 0.8 · π1 + 0.6 · π2, π2 = 0.2 · π1 + 0.4 · π2.

Note that the above two equations are dependent, since they are both equivalentto

π1 = 3π2.

This is a generic property, and in fact it can be shown that one of the balance equa-tions depends on the remaining equations (see the theoretical problems). However,we know that the πj satisfy the normalization equation

π1 + π2 = 1,

which supplements the balance equations and suffices to determine the πj uniquely.Indeed, by substituting the equation π1 = 3π2 into the equation π1 + π2 = 1, weobtain 3π2 + π2 = 1, or

π2 = 0.25,

which using the equation π1 + π2 = 1, yields

π1 = 0.75.

This is consistent with what we found earlier by iterating the Chapman-Kolmogorovequation (cf. Fig. 6.4).

Example 6.5. An absent-minded professor has two umbrellas that she uses whencommuting from home to office and back. If it rains and an umbrella is available in

† According to a famous and important theorem from linear algebra (called thePerron-Frobenius theorem), the balance equations always have a nonnegative solution,for any Markov chain. What is special about a chain that has a single recurrent class,which is aperiodic, is that the solution is unique and is also equal to the limit of then-step transition probabilities rij(n).

Page 345: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

16 Markov Chains Chap. 6

her location, she takes it. If it is not raining, she always forgets to take an umbrella.Suppose that it rains with probability p each time she commutes, independently ofother times. What is the steady-state probability that she gets wet on a given day?

We model this problem using a Markov chain with the following states:

State i: i umbrellas are available in her current location, i = 0, 1, 2.

The transition probability graph is given in Fig. 6.9, and the transition probabilitymatrix is [

0 0 10 1− p p

1 − p p 0

].

The chain has a single recurrent class that is aperiodic (assuming 0 < p < 1), sothe steady-state convergence theorem applies. The balance equations are

π0 = (1− p)π2, π1 = (1− p)π1 + pπ2, π2 = π0 + pπ1.

From the second equation, we obtain π1 = π2, which together with the first equationπ0 = (1− p)π2 and the normalization equation π0 + π1 + π2 = 1, yields

π0 =1 − p

3 − p, π1 =

1

3− p, π2 =

1

3 − p.

According to the steady-state convergence theorem, the steady-state probabilitythat the professor finds herself in a place without an umbrella is π0. The steady-state probability that she gets wet is π0 times the probability of rain p.

120

1

1 - p

1 - pp

p

No umbrellas Two umbrellas One umbrella

Figure 6.9: Transition probability graph for Example 6.5.

Example 6.6. A superstitious professor works in a circular building with mdoors, where m is odd, and never uses the same door twice in a row. Insteadhe uses with probability p (or probability 1 − p) the door that is adjacent in theclockwise direction (or the counterclockwise direction, respectively) to the door heused last. What is the probability that a given door will be used on some particularday far into the future?

Page 346: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.3 Steady-State Behavior 17

1 2

3

p 1 - p

1 - p

1 - p

1 - p p

p

p

Door 1

Door 3

Door 4

Door 2

5

4

Door 5 1 - p

p

Figure 6.10: Transition probability graph in Example 6.6, for the case ofm = 5 doors.

We introduce a Markov chain with the following m states:

State i: Last door used is door i, i = 1, . . . ,m.

The transition probability graph of the chain is given in Fig. 6.10, for the casem = 5. The transition probability matrix is

0 p 0 0 . . . 0 1− p1− p 0 p 0 . . . 0 0

0 1 − p 0 p . . . 0 0...

......

......

......

p 0 0 0 . . . 1− p 0

.

Assuming that 0 < p < 1, the chain has a single recurrent class that is aperiodic.[To verify aperiodicity, argue by contradiction: if the class were periodic, therecould be only two subsets of states such that transitions from one subset lead tothe other, since it is possible to return to the starting state in two transitions. Thus,it cannot be possible to reach a state i from a state j in both an odd and an evennumber of transitions. However, if m is odd, this is true for states 1 and m – acontradiction (for example, see the case where m = 5 in Fig. 6.10, doors 1 and 5 canbe reached from each other in 1 transition and also in 4 transitions).] The balanceequations are

π1 = (1− p)π2 + pπm,

πi = pπi−1 + (1− p)πi+1, i = 2, . . . , m− 1,

πm = (1− p)π1 + pπm−1.

These equations are easily solved once we observe that by symmetry, all doorsshould have the same steady-state probability. This suggests the solution

πj =1

m, j = 1, . . . ,m.

Page 347: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

18 Markov Chains Chap. 6

Indeed, we see that these πj satisfy the balance equations as well as the normal-ization equation, so they must be the desired steady-state probabilities (by theuniqueness part of the steady-state convergence theorem).

Note that if either p = 0 or p = 1, the chain still has a single recurrentclass but is periodic. In this case, the n-step transition probabilities rij(n) do notconverge to a limit, because the doors are used in a cyclic order. Similarly, if m iseven, the recurrent class of the chain is periodic, since the states can be groupedinto two subsets, the even and the odd numbered states, such that from each subsetone can only go to the other subset.

Example 6.7. A machine can be either working or broken down on a given day.If it is working, it will break down in the next day with probability b, and willcontinue working with probability 1 − b. If it breaks down on a given day, it willbe repaired and be working in the next day with probability r, and will continue tobe broken down with probability 1 − r. What is the steady-state probability thatthe machine is working on a given day?

We introduce a Markov chain with the following two states:

State 1: Machine is working, State 2: Machine is broken down.

The transition probability graph of the chain is given in Fig. 6.11. The transitionprobability matrix is [

1 − b br 1− r

].

This Markov chain has a single recurrent class that is aperiodic (assuming 0 < b < 1and 0 < r < 1), and from the balance equations, we obtain

π1 = (1− b)π1 + rπ2, π2 = bπ1 + (1− r)π2,

orbπ1 = rπ2.

This equation together with the normalization equation π1 + π2 = 1, yields thesteady-state probabilities

π1 =r

b + r, π2 =

b

b + r.

1 2

Working Broken

1 - b

r

b

1 - r

Figure 6.11: Transition probability graph for Example 6.7.

Page 348: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.3 Steady-State Behavior 19

The situation considered in the previous example has evidently the Markovproperty, i.e., the state of the machine at the next day depends explicitly only onits state at the present day. However, it is possible to use a Markov chain modeleven if there is a dependence on the states at several past days. The generalidea is to introduce some additional states which encode what has happened inpreceding periods. Here is an illustration of this technique.

Example 6.8. Consider a variation of Example 6.7. If the machine remainsbroken for a given number of ` days, despite the repair efforts, it is replaced by anew working machine. To model this as a Markov chain, we replace the single state2, corresponding to a broken down machine, with several states that indicate thenumber of days that the machine is broken. These states are

State (2, i): The machine has been broken for i days, i = 1, 2, . . . , `.

The transition probability graph is given in Fig. 6.12 for the case where ` = 4.Again this Markov chain has a single recurrent class that is aperiodic. From thebalance equations, we have

π1 = (1− b)π1 + r(π(2,1) + · · ·+ π(2,`−1)) + π(2,`),

π(2,1) = bπ1,

π(2,i) = (1− r)π(2,i−1), i = 2, . . . , `.

The last two equations can be used to express π(2,i) in terms of π1,

π(2,i) = (1− r)i−1bπ1, i = 1, . . . , `.

Substituting into the normalization equation π1 +∑`

i=1π(2,i) = 1, we obtain

1 =

(1 + b

i=1

(1− r)i−1

)π1 =

(1 +

b(1 − (1− r)`

)

r

)π1,

orπ1 =

r

r + b(1 − (1− r)`

) .

Using the equation π(2,i) = (1 − r)i−1bπ1, we can also obtain explicit formulas forthe π(2,i).

1 2,1

Working Broken

1 - br

b1 - r

2,2 2,3 2,41 - r 1 - r

rr

1

Figure 6.12: Transition probability graph for Example 6.8. A machine that hasremained broken for ` = 4 days is replaced by a new, working machine.

Page 349: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

20 Markov Chains Chap. 6

Long-Term Frequency Interpretations

Probabilities are often interpreted as relative frequencies in an infinitely longstring of independent trials. The steady-state probabilities of a Markov chainadmit a similar interpretation, despite the absence of independence.

Consider, for example, a Markov chain involving a machine, which at theend of any day can be in one of two states, working or broken-down. Each time itbreaks down, it is immediately repaired at a cost of $1. How are we to model thelong-term expected cost of repair per day? One possibility is to view it as theexpected value of the repair cost on a randomly chosen day far into the future;this is just the steady-state probability of the broken down state. Alternatively,we can calculate the total expected repair cost in n days, where n is very large,and divide it by n. Intuition suggests that these two methods of calculationshould give the same result. Theory supports this intuition, and in general wehave the following interpretation of steady-state probabilities (a justification isgiven in the theoretical problems section).

Steady-State Probabilities as Expected State Frequencies

For a Markov chain with a single class that is aperiodic, the steady-stateprobabilities πj satisfy

πj = limn→∞

vij(n)

n,

where vij(n) is the expected value of the number of visits to state j withinthe first n transitions, starting from state i.

Based on this interpretation, πj is the long-term expected fraction of timethat the state is equal to j. Each time that state j is visited, there is probabilitypjk that the next transition takes us to state k. We conclude that πjpjk canbe viewed as the long-term expected fraction of transitions that move the statefrom j to k.†

† In fact, some stronger statements are also true. Namely, whenever we carryout the probabilistic experiment and generate a trajectory of the Markov chain overan infinite time horizon, the observed long-term frequency with which state j is visitedwill be exactly equal to πj , and the observed long-term frequency of transitions fromj to k will be exactly equal to πjpjk. Even though the trajectory is random, theseequalities hold with certainty, that is, with probability 1. The exact meaning of thisstatement will become more apparent in the next chapter, when we discuss conceptsrelated to the limiting behavior of random processes.

Page 350: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.3 Steady-State Behavior 21

Expected Frequency of a Particular Transition

Consider n transitions of a Markov chain with a single class that is aperiodic,starting from a given initial state. Let qjk(n) be the expected number ofsuch transitions that take the state from j to k. Then, regardless of theinitial state, we have

limn→∞

qjk(n)

n= πjpjk.

The frequency interpretation of πj and πjpjk allows for a simple interpre-tation of the balance equations. The state is equal to j if and only if there is atransition that brings the state to j. Thus, the expected frequency πj of visits toj is equal to the sum of the expected frequencies πkpkj of transitions that leadto j, and

πj =

m∑

k=1

πkpkj ;

see Fig. 6.13.

1

2

j

m

π1p1j

p2j

pmjπm

π2

pj j π j

Figure 6.13: Interpretation of the balance equations in terms of frequencies.In a very large number of transitions, there will be a fraction πkpkj that bringthe state from k to j. (This also applies to transitions from j to itself, whichoccur with frequency πjpjj .) The sum of the frequencies of such transitions is thefrequency πj of being at state j.

Birth-Death Processes

A birth-death process is a Markov chain in which the states are linearly ar-ranged and transitions can only occur to a neighboring state, or else leave thestate unchanged. They arise in many contexts, especially in queueing theory.

Page 351: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

22 Markov Chains Chap. 6

Figure 6.14 shows the general structure of a birth-death process and also intro-duces some generic notation for the transition probabilities. In particular,

bi = P(Xn+1 = i + 1 |Xn = i), (“birth” probability at state i),

di = P(Xn+1 = i − 1 |Xn = i), (“death” probability at state i).

. . . m - 1 m

1 - dm

bm-2

0 1

b0

d1

1 - b1 - d11 - b0

b1

d2 dm-1

1 - bm-1 - dm-1

bm-1

dm

Figure 6.14: Transition probability graph for a birth-death process.

For a birth-death process, the balance equations can be substantially sim-plified. Let us focus on two neighboring states, say, i and i+1. In any trajectoryof the Markov chain, a transition from i to i+1 has to be followed by a transitionfrom i + 1 to i, before another transition from i to i + 1 can occur. Therefore,the frequency of transitions from i to i + 1, which is πibi, must be equal to thefrequency of transitions from i + 1 to i, which is πi+1di+1. This leads to thelocal balance equations†

πibi = πi+1di+1, i = 0, 1, . . . ,m− 1.

Using the local balance equations, we obtain

πi = π0b0b1 · · · bi−1

d1d2 · · ·di, i = 1, . . . , m.

Together with the normalization equation∑

i πi = 1, the steady-state probabil-ities πi are easily computed.

Example 6.9. (Random Walk with Reflecting Barriers) A person walksalong a straight line and, at each time period, takes a step to the right with prob-ability b, and a step to the left with probability 1 − b. The person starts in one of

† A more formal derivation that does not rely on the frequency interpretationproceeds as follows. The balance equation at state 0 is π0(1− b0) + π1d1 = π0, whichyields the first local balance equation π0b0 = π1d1.

The balance equation at state 1 is π0b0 + π1(1 − b1 − d1) + π2d2 = π1. Usingthe local balance equation π0b0 = π1d1 at the previous state, this is rewritten asπ1d1 + π1(1 − b1 − d1) + π2d2 = π1, which simplifies to π1b1 = π2d2. We can thencontinue similarly to obtain the local balance states at all other states.

Page 352: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.3 Steady-State Behavior 23

the positions 1, 2, . . . ,m, but if he reaches position 0 (or position m+ 1), his step isinstantly reflected back to position 1 (or position m, respectively). Equivalently, wemay assume that when the person is in positions 1 or m. he will stay in that positionwith corresponding probability 1 − b and b, respectively. We introduce a Markovchain model whose states are the positions 1, . . . , m. The transition probabilitygraph of the chain is given in Fig. 6.15.

21 . . . m - 1 m

b

1 - b

bb b

1 - b 1 - b 1 - b

1 - b b

Figure 6.15: Transition probability graph for the random walk Example 6.9.

The local balance equations are

πib = πi+1(1− b), i = 1, . . . ,m − 1.

Thus, πi+1 = ρπi, where

ρ =b

1− b,

and we can express all the πj in terms of π1, as

πi = ρi−1π1, i = 1, . . . ,m.

Using the normalization equation 1 = π1 + · · ·+ πm, we obtain

1 = π1(1 + ρ + · · ·+ ρm−1)

which leads to

πi =ρi−1

1 + ρ + · · · + ρm−1, i = 1, . . . ,m.

Note that if ρ = 1, then πi = 1/m for all i.

Example 6.10. (Birth-Death Markov Chains – Queueing) Packets arriveat a node of a communication network, where they are stored in a buffer and thentransmitted. The storage capacity of the buffer is m: if m packets are alreadypresent, any newly arriving packets are discarded. We discretize time in very smallperiods, and we assume that in each period, at most one event can happen thatcan change the number of packets stored in the node (an arrival of a new packet ora completion of the transmission of an existing packet). In particular, we assumethat at each period, exactly one of the following occurs:

Page 353: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

24 Markov Chains Chap. 6

(a) one new packet arrives; this happens with a given probability b > 0;

(b) one existing packet completes transmission; this happens with a given prob-ability d > 0 if there is at least one packet in the node, and with probability0 otherwise;

(c) no new packet arrives and no existing packet completes transmission; thishappens with a probability 1−b−d if there is at least one packet in the node,and with probability 1 − b otherwise.

We introduce a Markov chain with states 0, 1, . . . ,m, corresponding to thenumber of packets in the buffer. The transition probability graph is given inFig. 6.16.

The local balance equations are

πib = πi+1d, i = 0, 1, . . . ,m − 1.

We define

ρ =b

d,

and obtain πi+1 = ρπi, which leads to πi = ρiπ0 for all i. By using the normalizationequation 1 = π0 + π1 + · · ·+ πm, we obtain

1 = π0(1 + ρ + · · ·+ ρm

),

and

π0 =

1 − ρ

1− ρm+1if ρ 6= 1,

1

m + 1if ρ = 1.

The steady-state probabilities are then given by

πi =

ρi(1− ρ)

1− ρm+1if ρ 6= 1,

1

m + 1if ρ = 1,

i = 0, 1, . . . ,m.

0 1 . . . m - 1 m

b

d

1 - b - d1 - b 1 - dbb b

d d d

1 - b - d

Figure 6.16: Transition probability graph in Example 6.10.

Page 354: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.4 Absorption Probabilities and Expected Time to Absorption 25

It is interesting to consider what happens when the buffer size m is so largethat it can be considered as practically infinite. We distinguish two cases.

(a) Suppose that b < d, or ρ < 1. In this case, arrivals of new packets areless likely than departures of existing packets. This prevents the numberof packets in the buffer from growing, and the steady-state probabilities πi

decrease with i. We observe that as m →∞, we have 1 − ρm+1 → 1, and

πi → ρi(1− ρ), for all i.

We can view these as the steady-state probabilities in a system with an infinitebuffer. [As a check, note that we have

∑∞i=0

ρi(1− ρ) = 1.]

(b) Suppose that b > d, or ρ > 1. In this case, arrivals of new packets are morelikely than departures of existing packets. The number of packets in the buffertends to increase, and the steady-state probabilities πi increase with i. As weconsider larger and larger buffer sizes m, the steady-state probability of anyfixed state i decreases to zero:

πi → 0, for all i.

Were we to consider a system with an infinite buffer, we would have a Markovchain with a countably infinite number of states. Although we do not havethe machinery to study such chains, the preceding calculation suggests thatevery state will have zero steady-state probability and will be “transient.” Thenumber of packets in queue will generally grow to infinity, and any particularstate will be visited only a finite number of times.

6.4 ABSORPTION PROBABILITIES AND EXPECTED TIMETO ABSORPTION

In this section, we study the short-term behavior of Markov chains. We firstconsider the case where the Markov chain starts at a transient state. We areinterested in the first recurrent state to be entered, as well as in the time untilthis happens.

When focusing on such questions, the subsequent behavior of the Markovchain (after a recurrent state is encountered) is immaterial. We can thereforeassume, without loss of generality, that every recurrent state k is absorbing,i.e.,

pkk = 1, pkj = 0 for all j 6= k.

If there is a unique absorbing state k, its steady-state probability is 1 (becauseall other states are transient and have zero steady-state probability), and will bereached with probability 1, starting from any initial state. If there are multipleabsorbing states, the probability that one of them will be eventually reached isstill 1, but the identity of the absorbing state to be entered is random and the

Page 355: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

26 Markov Chains Chap. 6

associated probabilities may depend on the starting state. In the sequel, we fix aparticular absorbing state, denoted by s, and consider the absorption probabilityai that s is eventually reached, starting from i:

ai = P(Xn eventually becomes equal to the absorbing state s |X0 = i).

Absorption probabilities can be obtained by solving a system of linear equations,as indicated below.

Absorption Probability Equations

Consider a Markov chain in which each state is either transient or absorbing.We fix a particular absorbing state s. Then, the probabilities ai of eventuallyreaching state s, starting from i, are the unique solution of the equations

as = 1,

ai = 0, for all absorbing i 6= s,

ai =m∑

j=1

pijaj , for all transient i.

The equations as = 1, and ai = 0, for all absorbing i 6= s, are evidentfrom the definitions. To verify the remaining equations, we argue as follows. Letus consider a transient state i and let A be the event that state s is eventuallyreached. We have

ai = P(A |X0 = i)

=m∑

j=1

P(A |X0 = i, X1 = j)P(X1 = j |X0 = i) (total probability thm.)

=

m∑

j=1

P(A |X1 = j)pij (Markov property)

=

m∑

j=1

ajpij .

The uniqueness property of the solution of the absorption probability equationsrequires a separate argument, which is given in the theoretical problems section.

The next example illustrates how we can use the preceding method tocalculate the probability of entering a given recurrent class (rather than a givenabsorbing state).

Example 6.11. Consider the Markov chain shown in Fig. 6.17(a). We wouldlike to calculate the probability that the state eventually enters the recurrent class

Page 356: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.4 Absorption Probabilities and Expected Time to Absorption 27

4, 5 starting from one of the transient states. For the purposes of this problem,the possible transitions within the recurrent class 4, 5 are immaterial. We cantherefore lump the states in this recurrent class and treat them as a single absorbingstate (call it state 6); see Fig. 6.17(b). It then suffices to compute the probabilityof eventually entering state 6 in this new chain.

1

1 2 3 4 51

0.30.4

0.2

0.3

0.5

1

0.3 0.7

1 2 3 6

0.30.4

0.2

0.81

(a)

(b)

0.2

0.1

0.1

0.2

Figure 6.17: (a) Transition probability graph in Example 6.11. (b) A newgraph in which states 4 and 5 have been lumped into the absorbing states = 6.

The absorption probabilities ai of eventually reaching state s = 6 startingfrom state i, satisfy the following equations:

a2 = 0.2a1 + 0.3a2 + 0.4a3 + 0.1a6,

a3 = 0.2a2 + 0.8a6.

Using the facts a1 = 0 and a6 = 1, we obtain

a2 = 0.3a2 + 0.4a3 + 0.1,

a3 = 0.2a2 + 0.8.

This is a system of two equations in the two unknowns a2 and a3, which can bereadily solved to yield a2 = 21/31 and a3 = 29/31.

Example 6.12. (Gambler’s Ruin) A gambler wins $1 at each round, withprobability p, and loses $1, with probability 1 − p. Different rounds are assumed

Page 357: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

28 Markov Chains Chap. 6

independent. The gambler plays continuously until he either accumulates a tar-get amount of $m, or loses all his money. What is the probability of eventuallyaccumulating the target amount (winning) or of losing his fortune?

We introduce the Markov chain shown in Fig. 6.18 whose state i representsthe gambler’s wealth at the beginning of a round. The states i = 0 and i = mcorrespond to losing and winning, respectively.

All states are transient, except for the winning and losing states which areabsorbing. Thus, the problem amounts to finding the probabilities of absorptionat each one of these two absorbing states. Of course, these absorption probabilitiesdepend on the initial state i.

0 4

p

31 2

1 - p

pp

1 - p1 - p WinLose

Figure 6.18: Transition probability graph for the gambler’s ruin problem(Example 6.12). Here m = 4.

Let us set s = 0 in which case the absorption probability ai is the probabilityof losing, starting from state i. These probabilities satisfy

a0 = 1,

ai = (1− p)ai−1 + pai+1, i = 1, . . . ,m − 1,

am = 0.

These equations can be solved in a variety of ways. It turns out there is an elegantmethod that leads to a nice closed form solution.

Let us write the equations for the ai as

(1− p)(ai−1 − ai) = p(ai − ai+1), i = 1, . . . , m− 1.

Then, by denoting

δi = ai − ai+1, i = 1, . . . , m− 1,

and

ρ =1 − p

p,

the equations are written as

δi = ρδi−1, i = 1, . . . ,m − 1,

from which we obtain

δi = ρiδ0, i = 1, . . . , m− 1.

Page 358: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.4 Absorption Probabilities and Expected Time to Absorption 29

This, together with the equation δ0 + δ1 + · · ·+ δm−1 = a0 − am = 1, implies that

(1 + ρ + · · ·+ ρm−1

)δ0 = 1.

Thus, we have

δ0 =

1− ρ

1− ρmif ρ 6= 1,

1

mif ρ = 1,

and, more generally,

δi =

ρi(1− ρ)

1− ρmif ρ 6= 1,

1

mif ρ = 1.

From this relation, we can calculate the probabilities ai. If ρ 6= 1, we have

ai = a0 − δi−1 − · · · − δ0

= 1 − (ρi−1 + · · ·+ ρ + 1)δ0

= 1 − 1 − ρi

1− ρ· 1− ρ

1− ρm,

= 1 − 1 − ρi

1 − ρm,

and finally the probability of losing, starting from a fortune i, is

ai =ρi − ρm

1 − ρm, i = 1, . . . , m− 1.

If ρ = 1, we similarly obtain

ai =m− i

m.

The probability of winning, starting from a fortune i, is the complement 1−ai,and is equal to

1 − ai =

1− ρi

1 − ρm if ρ 6= 1,

i

mif ρ = 1.

The solution reveals that if ρ > 1, which corresponds to p < 1/2 and unfa-vorable odds for the gambler, the probability of losing approaches 1 as m → ∞regardless of the size of the initial fortune. This suggests that if you aim for a largeprofit under unfavorable odds, financial ruin is almost certain.

Page 359: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

30 Markov Chains Chap. 6

Expected Time to Absorption

We now turn our attention to the expected number of steps until a recurrentstate is entered (an event that we refer to as “absorption”), starting from aparticular transient state. For any state i, we denote

µi = E[number of transitions until absorption, starting from i

]

= E[minn ≥ 0 |Xn is recurrent

∣∣ X0 = i].

If i is recurrent, this definition sets µi to zero.We can derive equations for the µi by using the total expectation theorem.

We argue that the time to absorption starting from a transient state i is equalto 1 plus the expected time to absorption starting from the next state, whichis j with probability pij . This leads to a system of linear equations which isstated below. It turns out that these equations have a unique solution, but theargument for establishing this fact is beyond our scope.

Equations for the Expected Time to Absorption

The expected times µi to absorption, starting from state i are the uniquesolution of the equations

µi = 0, for all recurrent states i,

µi = 1 +

m∑

j=1

pijµj , for all transient states i.

Example 6.13. (Spiders and Fly) Consider the spiders-and-fly model of Ex-ample 6.2. This corresponds to the Markov chain shown in Fig. 6.19. The statescorrespond to possible fly positions, and the absorbing states 1 and m correspondto capture by a spider.

Let us calculate the expected number of steps until the fly is captured. Wehave

µ1 = µm = 0,

and

µi = 1 + 0.3 · µi−1 + 0.4 · µi + 0.3 · µi+1, for i = 2, . . . ,m − 1.

We can solve these equations in a variety of ways, such as for example bysuccessive substitution. As an illustration, let m = 4, in which case, the equationsreduce to

µ2 = 1 + 0.4 · µ2 + 0.3 · µ3, µ3 = 1 + 0.3 · µ2 + 0.4 · µ3.

Page 360: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.4 Absorption Probabilities and Expected Time to Absorption 31

The first equation yields µ2 = (1/0.6) + (1/2)µ3, which we can substitute in thesecond equation and solve for µ3. We obtain µ3 = 10/3 and by substitution again,µ2 = 10/3.

2 . . . m - 21

0.4 0.4 0.4 0.4

m - 1

0.3 0.3 0.3 0.3

0.3 0.3 0.3

0.31 3 m 1

0.3

Figure 6.19: Transition probability graph in Example 6.13.

Mean First Passage Times

The same idea used to calculate the expected time to absorption can be used tocalculate the expected time to reach a particular recurrent state, starting fromany other state. Throughout this subsection, we consider a Markov chain witha single recurrent class. We focus on a special recurrent state s, and we denoteby ti the mean first passage time from state i to state s, defined by

ti = E[number of transitions to reach s for the first time, starting from i

]

= E[minn ≥ 0 |Xn = s

∣∣ X0 = i].

The transitions out of state s are irrelevant to the calculation of the meanfirst passage times. We may thus consider a new Markov chain which is identicalto the original, except that the special state s is converted into an absorbingstate (by setting pss = 1, and psj = 0 for all j 6= s). We then compute ti as theexpected number of steps to absorption starting from i, using the formulas givenearlier in this section. We have

ti = 1 +m∑

j=1

pijtj, for all i 6= s,

ts = 0.

This system of linear equations can be solved for the unknowns ti, and is knownto have a unique solution.

The above equations give the expected time to reach the special state sstarting from any other state. We may also want to calculate the mean recur-rence time of the special state s, which is defined as

t∗s = E[number of transitions up to the first return to s, starting from s]

= E[minn > 1 |Xn = s

∣∣ X0 = s].

Page 361: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

32 Markov Chains Chap. 6

We can obtain t∗s, once we have the first passage times ti, by using the equation

t∗s = 1 +

m∑

j=1

psjtj .

To justify this equation, we argue that the time to return to s, starting from s,is equal to 1 plus the expected time to reach s from the next state, which is jwith probability psj . We then apply the total expectation theorem.

Example 6.14. Consider the “up-to-date”–“behind” model of Example 6.1.States 1 and 2 correspond to being up-to-date and being behind, respectively, andthe transition probabilities are

p11 = 0.8, p12 = 0.2,

p21 = 0.6, p22 = 0.4.

Let us focus on state s = 1 and calculate the mean first passage time to state 1,starting from state 2. We have t1 = 0 and

t2 = 1 + p21t1 + p22t2 = 1 + 0.4 · t2,from which

t2 =1

0.6=

5

3.

The mean recurrence time to state 1 is given by

t∗1 = 1 + p11t1 + p12t2 = 1 + 0 + 0.2 · 5

3=

4

3.

Summary of Facts About Mean First Passage Times

Consider a Markov chain with a single recurrent class, and let s be a par-ticular recurrent state.

• The mean first passage times ti to reach state s starting from i, arethe unique solution to the system of equations

ts = 0, ti = 1 +

m∑

j=1

pijtj , for all i 6= s.

• The mean recurrence time t∗s of state s is given by

t∗s = 1 +

m∑

j=1

psjtj.

Page 362: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 33

6.5 MORE GENERAL MARKOV CHAINS

The discrete-time, finite-state Markov chain model that we have considered sofar is the simplest example of an important Markov process. In this section,we briefly discuss some generalizations that involve either a countably infinitenumber of states or a continuous time, or both. A detailed theoretical develop-ment for these types of models is beyond our scope, so we just discuss their mainunderlying ideas, relying primarily on examples.

Chains with Countably Infinite Number of States

Consider a Markov process X1, X2, . . . whose state can take any positive inte-ger value. The transition probabilities

pij = P(Xn+1 = j |Xn = i), i, j = 1, 2, . . .

are given, and can be used to represent the process with a transition probabilitygraph that has an infinite number of nodes, corresponding to the integers 1, 2, . . .

It is straightforward to verify, using the total probability theorem in asimilar way as in Section 6.1, that the n-step transition probabilities

rij(n) = P(Xn = j |X0 = i), i, j = 1, 2, . . .

satisfy the Chapman-Kolmogorov equations

rij(n + 1) =

∞∑

k=1

rik(n)pkj , i, j = 1, 2, . . .

Furthermore, if the rij(n) converge to steady-state values πj as n →∞, then bytaking limit in the preceding equation, we obtain

πj =

∞∑

k=1

πkpkj , i, j = 1,2, . . .

These are the balance equations for a Markov chain with states 1, 2, . . .It is important to have conditions guaranteeing that the rij(n) indeed con-

verge to steady-state values πj as n →∞. As we can expect from the finite-statecase, such conditions should include some analog of the requirement that thereis a single recurrent class that is aperiodic. Indeed, we require that:

(a) each state is accessible from every other state;

(b) the set of all states is aperiodic in the sense that there is no d > 1 suchthat the states can be grouped in d > 1 disjoint subsets S1, . . . , Sd so thatall transitions from one subset lead to the next subset.

Page 363: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

34 Markov Chains Chap. 6

These conditions are sufficient to guarantee the convergence to a steady-state

limn→∞

rij(n) = πj , i, j = 1, 2, . . .

but something peculiar may also happen here, which is not possible if the numberof states is finite: the limits πj may not add to 1, so that (π1, π2, . . .) may notbe a probability distribution. In fact, we can prove the following theorem (theproof is beyond our scope).

Steady-State Convergence Theorem

Under the above accessibility and aperiodicity assumptions (a) and (b),there are only two possibilities:

(1) The rij(n) converge to a steady state probability distribution (π1, π2, . . .).In this case the πj uniquely solve the balance equations together withthe normalization equation π1 + π2 + · · · = 1. Furthermore, the πj

have an expected frequency interpretation:

πj = limn→∞

vij(n)

n,

where vij(n) is the expected number of visits to state j within the firstn transitions, starting from state i.

(2) All the rij(n) converge to 0 as n →∞ and the balance equations haveno solution, other than πj = 0 for all j.

For an example of possibility (2) above, consider the packet queueing sys-tem of Example 6.10 for the case where the probability b of a packet arrival ineach period is larger than the probability d of a departure. Then, as we sawin that example, as the buffer size m increases, the size of the queue will tendto increase without bound, and the steady-state probability of any one statewill tend to 0 as m → ∞. In effect, with infinite buffer space, the system is“unstable” when b > d, and all states are “transient.”

An important consequence of the steady-state convergence theorem is thatif we can find a probability distribution (π1, π2, . . .) that solves the balance equa-tions, then we can be sure that it is the steady-state distribution. This line ofargument is very useful in queueing systems as illustrated in the following twoexamples.

Example 6.15. (Queueing with Infinite Buffer Space) Consider, as in Ex-ample 6.10, a communication node, where packets arrive and are stored in a bufferbefore getting transmitted. We assume that the node can store an infinite number

Page 364: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 35

of packets. We discretize time in very small periods, and we assume that in eachperiod, one of the following occurs:

(a) one new packet arrives; this happens with a given probability b > 0;

(b) one existing packet completes transmission; this happens with a given prob-ability d > 0 if there is at least one packet in the node, and with probability0 otherwise;

(c) no new packet arrives and no existing packet completes transmission; thishappens with a probability 1−b−d if there is at least one packet in the node,and with probability 1 − b otherwise.

. . . b

d

0 1 . . . m - 1 m

b

d

1 - b - d1 - bbb b

d d d

1 - b - d 1 - b - d

Figure 6.20: Transition probability graph in Example 6.15.

We introduce a Markov chain with states are 0, 1, . . ., corresponding to thenumber of packets in the buffer. The transition probability graph is given inFig. 6.20. As in the case of a finite number of states, the local balance equationsare

πib = πi+1d, i = 0, 1, . . . ,

and we obtain πi+1 = ρπi, where ρ = b/d. Thus, we have πi = ρiπ0 for all i. Ifρ < 1, the normalization equation 1 =

∑∞i=0

πi yields

1 = π0

∞∑

i=0

ρi=

π0

1 − ρ,

in which case π0 = 1− ρ, and the steady-state probabilities are

πi = ρi(1− ρ), i = 0, 1, . . .

If ρ ≥ 1, which corresponds to the case where the arrival probability b is no lessthan the departure probability d, the normalization equation 1 = π0(1+ρ+ρ2+· · ·)implies that π0 = 0, and also πi = ρiπ0 = 0 for all i.

Example 6.16. (The M/G/1 Queue) Packets arrive at a node of a communi-cation network, where they are stored at an infinite capacity buffer and are thentransmitted one at a time. The arrival process of the packets is Poisson with rate

Page 365: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

36 Markov Chains Chap. 6

λ, and the transmission time of a packet has a given CDF. Furthermore, the trans-mission times of different packets are independent and are also independent fromall the interarrival times of the arrival process.

This queueing system is known as the M/G/1 system. With changes in ter-minology, it applies to many different practical contexts where “service” is providedto “arriving customers,” such as in communication, transportation, and manufac-turing, among others. The name M/G/1 is an example of shorthand terminologyfrom queueing theory, whereby the first letter (M in this case) characterizes thecustomer arrival process (Poisson in this case), the second letter (G in this case)characterizes the distribution of the service time of the queue (general in this case),and the number (1 in this case) characterizes the number of customers that can besimultaneously served.

To model this system as a discrete-time Markov chain, we focus on the timeinstants when a packet completes transmission and departs from the system. Wedenote by Xn the number of packets in the system just after the nth customer’sdeparture. We have

Xn+1 =

Xn − 1 + Sn if Xn > 0,Sn if Xn = 0,

where Sn is the number of packet arrivals during the (n+1)st packet’s transmission.In view of the Poisson assumption, the random variables S1, S2, . . . are independentand their PMF can be calculated using the given CDF of the transmission time,and the fact that in an interval of length r, the number of packet arrivals is Poisson-distributed with parameter λr. In particular, let us denote

αk = P(Sn = k), k = 0, 1, . . . ,

and let us assume that if the transmission time R of a packet is a discrete randomvariable taking the values r1, . . . , rm with probabilities p1, . . . , pm. Then, we havefor all k ≥ 0,

αk =

m∑

j=1

pje−λrj (λrj)

k

k!,

while if R is a continuous random variable with PDF fR(r), we have for all k ≥ 0,

αk =

∫ ∞

r=0

P(Sn = k |R = r)fR(r)dr =

∫ ∞

r=0

e−λr(λr)k

k!fR(r)dr.

The probabilities αk define in turn the transition probabilities of the Markov chainXn, as follows (see Fig. 6.21):

pij =

αj if i = 0 and j > 0,αj−i+1 if i > 0 and j ≥ i− 1,0 otherwise.

Clearly, this Markov chain satisfies the accessibility and aperiodicity condi-tions that guarantee steady-state convergence. There are two possibilities: either(π0, π1, . . .) form a probability distribution, or else πj > 0 for all j. We will clarify

Page 366: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 37

0 1 . . .

α0

2 3

α0

α1α1 α1

α0 α0

α1α2 α2

α2

α3

α3

Figure 6.21: Transition probability graph for the number of packets leftbehind by a packet completing transmission in the M/G/1 queue (Example6.16).

the conditions under which each of these cases holds, and we will also calculate thetransform M(s) (when it exists) of the steady-state distribution (π0, π1, . . .):

M (s) =

∞∑

j=0

πjesj .

For this purpose, we will use the transform of the PMF αk:

A(s) =

∞∑

j=0

αjesj.

Indeed, let us multiply the balance equations

πj = π0αj +

j+1∑

i=1

πiαj−i+1,

with esj and add over all j. We obtain

M (s) =

∞∑

j=0

π0αjesj +

∞∑

j=0

(j+1∑

i=1

πiαj−i+1

)esj

= A(s) +

∞∑

i=1

πies(i−1)

∞∑

j=i−1

αj−i+1es(j−i+1)

= A(s) +A(s)

es

∞∑

i=1

πiesi

= A(s) +A(s)

(M(s)− π0

)

es,

or

M(s) =(es − 1)π0A(s)

es − A(s).

Page 367: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

38 Markov Chains Chap. 6

To calculate π0, we take the limit as s → 0 in the above formula, and we use thefact M(0) = 1 when πj is a probability distribution. We obtain, using the factA(0) = 1 and L’Hospital’s rule,

1 = lims→0

(es − 1)π0A(s)

es −A(s)=

π0

1−(dA(s)/ds

)∣∣s=0

=π0

1− E[N ],

where E[N ] =∑∞

j=0jαj is the expected value of the number N of packet arrivals

within a packet’s transmission time. Using the iterated expectations formula, wehave

E[N ] = λE[R],

where E[R] is the expected value of the transmission time. Thus,

π0 = 1− λE[R],

and the transform of the steady-state distribution πj is

M(s) =(es − 1)

(1− λE[R]

)A(s)

es − A(s).

For the above calculation to be correct, we must have E[N ] < 1, i.e., packets shouldarrive at a rate that is smaller than the transmission rate of the node. If this is nottrue, the system is not “stable” and there is no steady-state distribution, i.e., theonly solution of the balance equations is πj = 0 for all j.

Let us finally note that we have introduced the πj as the steady-state prob-ability that j packets are left behind in the system by a packet upon completingtransmission. However, it turns out that πj is also equal to the steady-state prob-ability of j packets found in the system by an observer that looks at the system ata “typical” time far into the future. This is discussed in the theoretical problems,but to get an idea of the underlying reason, note that for each time the number ofpackets in the system increases from n to n + 1 due to an arrival, there will be acorresponding future decrease from n + 1 to n due to a departure. Therefore, inthe long run, the frequency of transitions from n to n + 1 is equal to the frequencyof transitions from n + 1 to n. Therefore, in steady-state, the system appearsstatistically identical to an arriving and to a departing packet. Now, because thepacket interarrival times are independent and exponentially distributed, the timesof packet arrivals are “typical” and do not depend on the number of packets inthe system. With some care this argument can be made precise, and shows thatat the times when packets complete their transmissions and depart, the system is“typically loaded.”

Continuous-Time Markov Chains

We have implicitly assumed so far that the transitions between states take unittime. When the time between transitions takes values from a continuous range,some new questions arise. For example, what is the proportion of time that the

Page 368: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 39

system spends at a particular state (as opposed to the frequency of visits intothe state)?

Let the states be denoted by 1, 2, . . ., and let us assume that state tran-sitions occur at discrete times, but the time from one transition to the next israndom. In particular, we assume that:

(a) If the current state is i, the next state will be j with a given probabilitypij .

(b) The time interval ∆i between the transition to state i and the transitionto the next state is exponentially distributed with a given parameter νi:

P(∆i ≤ δ | current state is i) ≤ 1− e−νiδ.

Furthermore, ∆i is independent of earlier transition times and states.

The parameter νi is referred to as the transition rate associated with statei. Since the expected transition time is

E[∆i] =

∫ ∞

0

δνie−νiδdδ =1

νi,

we can interpret νi as the average number of transitions per unit time. We mayalso view

qij = pijνi

as the rate at which the process makes a transition to j when at state i. Con-sequently, we call qij the transition rate from i to j. Note that given thetransition rates qij , one can obtain the node transition rates using the formulaνi =

∑∞j=1 qij .

The state of the chain at time t ≥ 0 is denoted by X(t), and stays constantbetween transitions. Let us recall the memoryless property of the exponentialdistribution, which in our context implies that, for any time t between the kthand (k + 1)st transition times tk and tk+1, the additional time tk+1 − t neededto effect the next transition is independent of the time t − tk that the systemhas been in the current state. This implies the Markov character of the process,i.e., that at any time t, the future of the process, [the random variables X(t) fort > t] depend on the past of the process [the values of the random variables X(t)for t ≤ t] only through the present value of X(t).

Example 6.17. (The M/M/1 Queue) Packets arrive at a node of a communi-cation network according to a Poisson process with rate λ. The packets are storedat an infinite capacity buffer and are then transmitted one at a time. The trans-mission time of a packet is exponentially distributed with parameter µ, and thetransmission times of different packets are independent and are also independentfrom all the interarrival times of the arrival process. Thus, this queueing system isidentical to the special case of the M/G/1 system, where the transmission times areexponentially distributed (this is indicated by the second M in the M/M/1 name).

Page 369: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

40 Markov Chains Chap. 6

We will model this system using a continuous-time process with state X(t)equal to the number of packets in the system at time t [if X(t) > 0, then X(t)− 1packets are waiting in the queue and one packet is under transmission]. The stateincreases by one when a new packet arrives and decreases by one when an existingpacket departs. To show that this process is a continuous-time Markov chain, letus identify the transition rates νi and qij at each state i.

Consider first the case where at some time t, the system becomes empty,i.e., the state becomes equal to 0. Then the next transition will occur at the nextarrival, which will happen in time that is exponentially distributed with parameterλ. Thus at state 0, we have the transition rates

q0j =

λ if j = 1,0 otherwise.

Consider next the case of a positive state i, and suppose that a transition oc-curs at some time t to X(t) = i. If the next transition occurs at time t+∆i, then ∆i

is the minimum of two exponentially distributed random variables: the time to thenext arrival, call it Y, which has parameter λ, and the time to the next departure,call it Z, which has parameter µ. (We are again using here the memoryless propertyof the exponential distribution.) Thus according to Example 5.15, which deals with“competing exponentials,” the time ∆i is exponentially distributed with parameterνi = λ + µ. Furthermore, the probability that the next transition corresponds toan arrival is

P(Y ≤ Z) =

y≤z

λe−λy · µe

µzdy dz

= λµ

∫ ∞

0

e−λy

(∫ ∞

y

eµz dz

)dy

= λµ

∫ ∞

0

e−λy

(e−µy

µ

)dy

= λ

∫ ∞

0

e−(λ+µ)y

dy

λ + µ.

We thus have for i > 0, qi,i+1 = νiP(Y ≤ Z) = (λ + µ)(λ/(λ + µ)

)= λ. Similarly,

we obtain that the probability that the next transition corresponds to a departureis µ/(λ + µ), and we have qi,i−1 = νiP(Y ≥ Z) = (λ + µ)

(µ/(λ + µ)

)= µ. Thus

qij =

λ if j = i + 1,µ if j = i− 1,0 otherwise.

The positive transition rates qij are recorded next to the arcs (i, j) of the transitiondiagram, as in Fig. 6.22.

We will be interested in chains for which the discrete-time Markov chaincorresponding to the transition probabilities pij satisfies the accessibility and

Page 370: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 41

. . . 0 1 . . . m - 1 m

λ

µ

λ λ λ λ

µ µ µµ

Figure 6.22: Transition graph for the M/M/1 queue (Example 6.17).

aperiodicity assumptions of the preceding section. We also require a technicalcondition, namely that the number of transitions in any finite length of timeis finite with probability one. Almost all models of practical use satisfy thiscondition, although it is possible to construct examples that do not.

Under the preceding conditions, it can be shown that the limit

πj = limt→∞

P(X(t) = j |X(0) = i

)

exists and is independent of the initial state i. We refer to πj as the steady-stateprobability of state j. It can be shown that if Tj(t) is the expected value of thetime spent in state j up to time t, then, regardless of the initial state, we have

πj = limt→∞

Tj(t)

t

that is, πj can be viewed as the long-term proportion of time the process spendsin state j.

The balance equations for a continuous-time Markov chain take the form

pj

∞∑

i=0

qji =

∞∑

i=0

piqij , j = 0, 1, . . .

Similar to discrete-time Markov chains, it can be shown that there are twopossibilities:

(1) The steady-state probabilities are all positive and solve uniquely the bal-ance equations together with the normalization equation π1 +π2 + · · · = 1.

(2) The steady-state probabilities are all zero.

To interpret the balance equations, we note that since πi is the proportionof time the process spends in state i, it follows that πiqij can be viewed asfrequency of transitions from i to j (expected number of transitions from i toj per unit time). It is seen therefore that the balance equations express theintuitive fact that the frequency of transitions out of state j (the left side termπj

∑∞i=1 qji) is equal to the frequency of transitions into state j (the right side

term∑∞

i=0 πiqij).The continuous-time analog of the local balance equations for discrete-time

chains isπjqji = πiqij , i, j = 1, 2, . . .

Page 371: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

42 Markov Chains Chap. 6

These equations hold in birth-death systems where qij = 0 for |i − j| > 1, butneed not hold in other types of Markov chains. They express the fact that thefrequencies of transitions from i to j and from j to i are equal.

To understand the relationship between the balance equations for continuous-time chains and the balance equations for discrete-time chains, consider anyδ > 0, and the discrete-time Markov chain Zn |n ≥ 0, where

Zn = X(nδ), n = 0,1, . . .

The steady-state distribution of Zn is clearly πj | j ≥ 0, the steady-statedistribution of the continuous chain. The transition probabilities of Zn |n ≥ 0can be derived by using the properties of the exponential distribution. We obtain

pij = δqij + o(δ), i 6= j,

pjj = 1− δ

∞∑

i=0i6=j

qji + o(δ)

Using these expressions, the balance equations

πj =

∞∑

i=0

πi pij j ≥ 0

for the discrete-time chain Zn, we obtain

πj =

∞∑

i=0

πipij = pj

(1− δ

∞∑

i=0i6=j

qji + o(δ))

+∑

i=0i6=j

pi

(δqij + o(δ)

).

Taking the limit as δ → 0, we obtain the balance equations for the continuous-time chain.

Example 6.18. (The M/M/1 Queue – Continued) As in the case of a finitenumber of states, the local balance equations are

πiλ = πi+1µ, i = 0, 1, . . . ,

and we obtain πi+1 = ρπi, where ρ = λ/µ. Thus, we have πi = ρiπ0 for all i. Ifρ < 1, the normalization equation 1 =

∑∞i=0

πi yields

1 = π0

∞∑

i=0

ρi =π0

1 − ρ,

in which case π0 = 1− ρ, and the steady-state probabilities are

πi = ρi(1− ρ), i = 0, 1, . . .

Page 372: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 43

If ρ ≥ 1, which corresponds to the case where the arrival probability b is no lessthan the departure probability d, the normalization equation 1 = π0(1+ρ+ρ2+· · ·)implies that π0 = 0, and also πi = ρiπ0 = 0 for all i.

Example 6.19. (The M/M/m and M/M/∞ Queues) The M/M/m queueingsystem is identical to the M/M/1 system except that m packets can be simul-taneously transmitted (i.e., the transmission line of the node has m transmissionchannels). A packet at the head of the queue is routed to any channel that isavailable. The corresponding state transition diagram is shown in Fig. 6.24.

. . . λ

0 1 . . . m - 1 m

λ

µ

λ λ λ

2µ (m - 1)µ mµmµ

m+1

λ

Figure 6.24: Transition graph for the M/M/m queue (Example 6.19).

By writing down the local balance equations for the steady-state probabilitiesπn, we obtain

λπn−1 =

nµπn if n ≤ m,mµπn if n > m.

From these equations, we obtain

πn =

p0(mρ)n

n!, n ≤m

p0mmρn

m!, n > m

where ρ is given by

ρ =λ

mµ.

Assuming ρ < 1, we can calculate π0 using the above equations and the condition∑∞n=0

πn = 1. We obtain

π0 =

(1 +

m−1∑

n=1

(mρ)n

n!+

∞∑

n=m

(mρ)n

m!

1

mn−m

)−1

and, finally,

π0 =

(m−1∑

n=0

(mρ)n

n!+

(mρ)m

m!(1− ρ)

)−1

.

Page 373: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

44 Markov Chains Chap. 6

In the limiting case where m = ∞ in the M/M/m system (which is calledthe M/M/∞ system), the local balance equations become

λπn−1 = nµπn, n = 1, 2, . . .

so

πn = π0

µ

)n1

n!, n = 1, 2, . . .

From the condition∑∞

n=0πn = 1, we obtain

π0 =

(1 +

∞∑

n=1

µ

)n1

n!

)−1

= e−λ/µ,

so, finally,

πn =

µ

)ne−λ/µ

n!, n = 0, 1, . . .

Therefore, in steady-state, the number in the system is Poisson distributed withparameter λ/µ.

Page 374: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 45

S O L V E D P R O B L E M S

SECTION 6.1. Discrete-Time Markov Chains

SECTION 6.2. Classification of States

Problem 1. * Existence of a Recurrent State. Show that in a Markov chain atleast one recurrent state must be accessible from any given state, i.e., for any i, thereis at least one recurrent j in the set A(i) of accessible states from i.

Solution. Start with a state i. If A(i) contains a recurrent state we are done; otherwisechoose a transient state i1 ∈ A(i) such that i /∈ A(i1) and hence also i1 6= i [such astate must exist for otherwise i and all the states in A(i) would form a recurrent class].If A(i1) contains a recurrent state we are done; otherwise choose a transient statei2 ∈ A(i1) such that i1 /∈ A(i2) and hence also i1 6= i2 [such a state must exist forotherwise i1 and all the states in A(i1) would form a recurrent class]. Note that wemust have i2 6= i for otherwise we would be able to come back to i from i1 throughi2. Continuing this process, at the kth step, we will either obtain a recurrent state ikwhich is accessible from i, or else we will obtain a transient state ik which is differentthan all the preceding states i, i1, . . . , ik−1. Since there is only a finite number of states,a recurrent state must ultimately be obtained.

Problem 2. * Periodic Classes.

(a) Show that a recurrent class is periodic if and only if there exists an integer d > 1such that for all states i in the class, if n is not an integer multiple of d, thenrii(n) = 0.

(b) Show that a recurrent class is not periodic if and only if we can find a time n anda special state s in the class such that ris(n) > 0 for all i in the class and n ≥ n.

SECTION 6.3. Steady-State Behavior

Problem 3. The book pile problem. A professor has m probability books, whichshe keeps in a pile. Occasionally she picks out a book from the pile (independently ofpast choices) and after using it, she places it at the top of the pile. Show that if theith book is picked up with probability βi and βi > 0 for all i, then the steady-stateprobability that this book is at the top of the pile is also βi.

Solution. Let the states be 1, . . . ,m, where state j corresponds to the jth book beingat the top. The transition probabilities are

pij = βj, i, j = 1, . . . ,m.

The chain has a single recurrent class which is aperiodic, so steady-state probabilitiesπj and solve uniquely the normalization equation π1 + · · · + πm = 1 together with the

Page 375: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

46 Markov Chains Chap. 6

balance equations

πj =

m∑

i=1

πipij , j = 1, . . . ,m.

It is seen that πj = βj solve these equations, so they are the unique steady-stateprobabilities.

Problem 4. A particular professor gives tests that are either hard, medium, or easy.Fortunately, she never gives two hard tests in a row. If she gives a hard test, her nexttest is equally likely to be either medium or easy. However, if she gives a mediumor easy test, there is a 50% chance that her next test will be of the same difficulty,and a 25% chance that it will be either of the two other difficulties. Formulate theappropriate Markov Chain and find the steady state probabilities.

Solution. We use a Markov chain model with 3 states, where the state is the difficultyof the most recent exam

S1 = H,S2 = M,S3 = E.

We are given the transition probabilities

(rHH rHM rHE

rMH rMM rME

rEH rEM rEE

)=

(0 .5 .5

.25 .5 .25

.25 .25 .5

).

It is easy to see that our Markov chain has a single, aperiodic recurrent class. Thus wecan use the steady-state convergence theorem which tells us that if we can find πithat satisfy πj =

∑iπipij and

∑iπi = 1 then the πi are in fact the steady state

probabilities. Therefore we have πj =∑

iπipij, i.e.,

1

4(π2 + π3) = π1

1

2(π1 + π2) +

1

4π3 = π2

1

2(π1 + π3) +

1

4π2 = π3

and solving these with the constraint∑

iπi = 1 gives

π1 =1

5, π2 = π3 =

2

5.

Problem 5. Alvin likes to sail each Saturday to his cottage on a nearby island offthe coast. Alvin is an avid fisherman, and enjoys fishing off his boat on the way to andfrom the island, as long as the weather is good. Unfortunately, the weather is good onthe way to or from the island with probability p, independently of what the weatherwas on any past trip (so the weather could be nice on the way to the island, but pooron the way back). Now, if the weather is nice, Alvin will take one of his n fishing rodsfor the trip, but if the weather is bad, he will not bring a fishing rod with him. Wewant to find the probability that on a given leg of the trip to or from the island theweather will be nice, but Alvin will not fish because all his fishing rods are at his otherhome.

Page 376: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 47

(a) Formulate an appropriate Markov chain model with n + 1 states and find thesteady-state probabilities.

(b) What is the probability that on a given trip, Alvin sails with nice weather butwithout a fishing rod?

(c) If Alvin owns 4 fishing rods, find p such that the time he wants to, but cannotfish is maximized.

Solution. (a) We need to know the number of fishing rods on and off the island. It isenough to know the number of fishing rods off the island. Therefore the states of ourchain will be the number of fishing rods off the island. We will consider the state of thechain after a round trip to and from the island. This is a birth-death Markov chain,since the only states that are adjacent are states Si, Si+1 for appropriate i. Note thatbecause of this, the number of transitions from state i to state i+1 must be within 1 ofthe number of transitions from state i+1 to state i. Therefore since we are seeking thesteady state probabilities, we can equate the two. Before we can solve these equationsfor the limiting probabilities, we need to find the transition probabilities

pii =

(1− p)2 + p2 for i ≥ 1,(1− p) for i = 0.

pi,i+1 =

(1− p)p for 1 ≤ i < n,p for i = 0.

pi,i−1 =

(1− p)p for 1 ≤ i.0 for i = 0.

Thus we haveπ0p01 = π1p10,

implying

π1 =π0

1− p

and similarly,

πn = · · · = π2 = π1 =π0

1− p

thus we have ∑

i

π1 = π0(1 +n

1 − p) = 1,

thus yielding

π0 =1 − p

n + 1− p, πi =

1

n + 1− p, for all i > 0.

(b) Let A denote the event that the weather is nice but Alvin has no fishing rods withhim. Then

P (A) = πn(1− p)p + π0(p) =2p− 2p2

n + 1− p.

(c) If n = 4 we have

P (A) =2p− 2p2

5 − p

Page 377: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

48 Markov Chains Chap. 6

and we can maximize this by taking a derivative with respect to p and setting equal tozero. Solving, we find that the “optimal” value of p is

p = 5 − 2√

5.

Problem 6. Bernoulli-Laplace model of diffusion. Each of two urns containsm balls. Out of the total of the 2m balls, m are white and m are black. A ball issimultaneously selected from each urn and moved to the other urn, an the process isindefinitely repeated, What is the steady-state distribution of the number of balls ineach urn?

Solution. Let j = 0, 1 . . . , m be the states, with state j corresponding to the first urncontaining j white balls. The nonzero transition probabilities are

pj,j−1 =(

j

m

)2

, pj,j+1 =(

m− j

m

)2

, pjj =2j(m − j)

m2.

The chain has a single recurrent class that is aperiodic. From the balance equations,the steady-state probabilities can be shown to be

πj =

(mj

)2

(2mm

) , j = 0, 1, . . . ,m.

Problem 7. * Consider a Markov chain with two states denoted 1 and 2, andtransition probabilities

p11 = 1− α, p12 = α,

p21 = β, p22 = 1 − β,

where α and β are such that either 0 < α < 1 or 0 < β < 1 (or both).

(a) Show that the two states of the chain form a recurrent and aperiodic class.

(b) Use induction to show that for all n, we have

r11(n) =β

α + β+

α(1− α− β)n

α + β, r12(n) =

α

α + β− α(1− α− β)n

α + β,

r21(n) =β

α + β− β(1− α− β)n

α + β, r22(n) =

α

α + β+

β(1− α− β)n

α + β.

(c) What are the steady-state probabilities π1 and π2?

Solution. (a) The states form a recurrent class since all possible transitions havepositive probability. The class is aperiodic since state 1 (as well as state 2) can bereached in one step starting from any state.

(b) The Chapman-Kolmogorov equations are

rij(n) =

2∑

k=1

rik(n − 1)pkj , for n > 1, and i, j = 1, 2,

Page 378: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 49

starting with rij(1) = pij, so they have the form

r11(n) = r11(n− 1)(1− α) + r12(n− 1)β, r12(n) = r11(n− 1)α + r12(n− 1)(1− β),

r21(n) = r21(n− 1)(1− α) + r22(n− 1)β, r22(n) = r21(n− 1)α + r22(n− 1)(1− β).

If the rij(n−1) have the form given, it is easily verified by substitution in the Chapman-Kolmogorov equations that the rij(n) also have the form given.

(c) The steady-state probabilities π1 and π2 are obtained by taking the limit of ri1(n)and ri2(n), respectively, as n →∞. Thus, we have

π1 =β

α + β, π2 =

α

α + β.

Problem 8. * The parking garage at MIT has installed a card operated gate,which, unfortunately, is vulnerable to absent-minded faculty and staff. In particular,in each day a car crashes the gate with probability p, in which case a new gate mustbe installed. Also a gate that has survived for m days must be replaced as a matter ofperiodic maintenance. What is the long-term expected frequency of gate replacements?

Solution. Let the state be the number of days that the gate has survived. The balanceequations are

π0 = π0p + π1p + · · ·+ πm−1p + πm,

π1 = π0(1− p),

π2 = π1(1− p) = π0(1− p)2,

and similarlyπi = π0(1− p)i, i = 1, . . . ,m.

We have using the normalization equation

1 = π0 +

m∑

i=1

πi = π0

(1 +

m∑

i=1

(1− p)i

),

soπ0 =

p

1 − (1− p)m+1.

The long-term expected frequency of gate replacements is equal to the long-term ex-pected frequency of visits to state 0, which is π0.

Problem 9. * Doubly Stochastic Matrices. Consider an irreducible and aperiodicMarkov chain whose transition probability matrix is doubly stochastic, i.e., it hasthe property that all its columns (as well as all its rows) add to unity:

n∑

i=1

pij = 1, for all j = 1, . . . ,m.

(a) Show that the transition probability matrix of the chain in Example 6.6 is doublystochastic.

Page 379: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

50 Markov Chains Chap. 6

(b) Show that the steady-state probabilities are

πj =1

m, j = 1, . . . ,m.

(c) Suppose that the recurrent class of the chain is instead periodic. Use the resultsof Problem 5 to show that πj = 1

mfor all j are the unique solution of the balance

equations. Discuss your answer in the context of Example 6.6 for the case wherem is even.

Solution. (a) Indeed the rows and the columns of the transition probability matrix inthis example all add to 1.

(b) It is seen that the given probabilities πj = 1/m indeed satisfy the balance equations.

(c) If m is even in Example 6.6, the chain is periodic with period 2. Despite this factπj = 1/m solve uniquely the balance equations.

Problem 10. * Consider the queueing Example 6.10, but assume that the probabil-ities of a packet arrival and a packet transmission depend on the state of the queue. Inparticular, in each period where there are i packets in the node, one of the followingoccurs:

(1) One new packet arrives; this happens with a given probability bi > 0.

(2) One existing packet completes transmission; this happens with a given probabilitydi > 0 if i ≥ 1, and with probability 0 otherwise.

(3) No new packet arrives and no existing packet completes transmission; this hap-pens with a probability 1− bi− di if i ≥ 1, and with probability 1− bi otherwise.

Calculate the steady-state probabilities of the corresponding Markov chain.

Solution. We introduce a Markov chain where the states are 0, 1, . . . ,m and correspondto the number of packets currently stored at the node. The transition probability graphis given in Fig. 6.25.

0 1 . . . m - 1 m

p0

q1

1 - p1 - q11 - p0 1 - qmpm-1p1 pm-2

q2 qm-1 qm

1 - pm-1 - qm-1

Figure 6.25: Transition probability graph for the queueing problem.

Similar to Example 6.10, the balance equations are easily solved by applying theformula

Frequency of transitions into S = Frequency of transitions out of S

forS = 0, 1, . . . , i, i = 0, 1, . . . , m − 1.

Page 380: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 51

We obtain

πibi = πi+1di+1, i = 0, 1, . . . ,m − 1.

Thus we have πi+1 = ρiπi where

ρi =bi

di+1.

Hence πi = (ρ0 · · · ρi−1)π0 for all i = 1, . . . ,m. By using the normalization equation1 = π0 + π1 + · · ·+ πm, we obtain

1 = π0(1 + ρ0 + · · ·+ ρ0 · · · ρm−1),

from which

π0 =1

1 + ρ0 + · · ·+ ρ0 · · · ρm−1.

The remaining steady-state probabilities are

πi =ρ0 · · · ρi−1

1 + ρ0 + · · · + ρ0 · · · ρm−1, i = 1, . . . ,m.

Problem 11. * Dependence of the Balance Equations. Show that if we addthe first m − 1 balance equations πj =

∑m

k=1πkpkj, j = 1, . . . , m − 1, we obtain the

last equation πm =∑m

k=1πkpkm.

Solution. By adding the first m − 1 balance equations, we obtain

m−1∑

j=1

πj =

m−1∑

j=1

m∑

k=1

πkpkj

=

m∑

k=1

πk

m−1∑

j=1

pkj

=

m∑

k=1

πk(1− pkm)

= πm +

m−1∑

k=1

πk −m∑

k=1

πkpkm.

This equation is equivalent to the last balance equation πm =∑m

k=1πkpkm.

Problem 12. * Local Balance Equations. Given a Markov chain with transitionprobabilities pij, i, j = 1, . . . , m, and a single class that is aperiodic, suppose that wehave found a solution (π1, . . . , πm) to the following system of local balance equations

πipij = πjpji, i, j = 1, . . . ,m,

m∑

i=1

πi = 1, πi ≥ 0, i = 1, . . . , m.

Page 381: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

52 Markov Chains Chap. 6

(a) Show that the πj are the unique steady-state probabilities. Hint: Given a statej, add the local balance equations corresponding to the pairs of the form (i, j).

(b) What is the interpretation of the equations πipij = πjpji in terms of steady-stateexpected frequencies of transition between i and j?

(c) Show that the local balance equations hold for any birth-death Markov chain.

(d) Construct an example of a Markov chain with a single class that is aperiodic,where the local balance equations are not satisfied by the steady-state probabil-ities.

Solution. (a) By adding the local balance equations πipij = πjpji over i, we obtain

m∑

i=1

πipij =

m∑

i=1

πjpji = πj,

so the πj also satisfy the balance equations. Therefore, they are equal to the steady-state probabilities.

(b) We know that πipij can be interpreted as the expected long-term frequency oftransitions from i to j, so the local balance equations imply that the expected long-term frequency of any transition is equal to the expected long-term frequency of thereverse transition. (This property is also known as time reversibility of the chain.)

(c) In any Markov chain, given a subset of states S, the expected long-term frequencyof transitions form states in S to states in the complementary set S, is equal to theexpected long-term frequency of transitions form states in S to states in S. Applyingthis property to a birth-death Markov chain to the sets S = 1, . . . , i and S = i +1, . . . ,m, we obtain the local balance equations.

(d) We need a minimum of three states for such an example. Let the states be 1, 2, 3,and let p12 > 0, p13 > 0, p21 > 0, p32 > 0, with all other transition probabilities being0. The chain has a single recurrent aperiodic class. The local balance equations donot hold because the expected frequency of transitions from 1 to 3 is positive, but theexpected frequency of reverse transitions is 0.

Problem 13. * Sampled Markov chains. Consider a Markov chain X1, X2, . . .with transition probabilities pij, i, j = 1, . . . ,m, and let rij(n) be the n-step transitionprobabilities.

(a) Show that for all n ≥ 1 and l ≥ 1, we have

rij(n + l) =

m∑

k=1

rik(n)rkj(l).

(b) Let the Markov chain have a single recurrent class that is aperiodic. Supposethat the process is sampled every l transitions, thus generating the processY1, Y2, . . ., where Yn = Xln. Show that the sampled process can be mod-eled by a Markov chain with a single aperiodic recurrent class and transitionprobabilities rij(l).

(c) Use part (a) to show that the sampled process of part (b) has the same steady-state probabilities as the original process.

Page 382: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 53

Problem 14. * Given an irreducible and aperiodic Markov chain Xn, consider theMarkov chain whose state at time n is Xn−1, Xn (thus the state in the new chaincan be associated with the last transition in the original chain).

(a) Show that the steady-probabilities are

ηij = πipij.

(b) Generalize part (a) to the case of the Markov chain Xn, Xn+1, . . . ,Xn+k, whosestate can be associated with the last k transitions of the original chain.

(c) Consider an infinite sequence of independent coin tosses, where the probabilityof a head is p. Each time the coin comes up heads twice in a row you get $1(so the sequence THHHHT gets you $3). What is the (approximate) expectedamount of money that you will get per coin toss, averaged over a large numberof coin tosses.

SECTION 6.4. Absorption Probabilities and Expected Time to Ab-sorption

Problem 15. There are m classes offered by a particular department, and eachyear, the students rank each class from 1 to m, in order of difficulty. Unfortunately,the ranking is completely arbitrary. In fact, any given class is equally likely to receiveany given rank on a given year (two classes may not receive the same rank). A certainprofessor chooses to remember only the highest ranking his class has ever gotten.

(a) Find the transition probabilities of the Markov chain that models the rankingthat the professor remembers.

(b) Find the recurrent and the transient states.

(c) Find the expected number of years for the professor to achieve the highest rankinggiven that in the first year he achieved the ith ranking.

Solution. (a) For i > j, we have pij = 0. Since the professor will continue toremember the highest ranking, even if he gets a lower ranking in a subsequent year, wehave pii = i/m. Finally, for j > i, we have pij = 1/m, since the class is equally likelyto receive any given rating.

(b) There is a positive probability that on any given year, the professor will receive thehighest ranking, namely 1/m. Therefore the probability that he does not receive thisranking in n years is

(m−1

m

)nand this probability goes to 0 as n → ∞. As a result,

he is guaranteed of eventually receiving the highest ranking. Now note that this stateis absorbing. It is the only recurrent state in the Markov chain. All other states aretransient.

(c) This question can be answered by finding the mean first passage time to the ab-sorbing state m starting from i. It is simpler though to argue as follows: since theprobability of achieving the highest ranking in a given year is 1/m, independently ofthe current state, the required expected number of years is the expected number oftrials to the first success in a Bernoulli process with success probability 1/m. Thus,the expected number of years is m.

Page 383: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

54 Markov Chains Chap. 6

Problem 16. * Mean First Passage Times. Consider a Markov chain with asingle recurrent class, and let s be a fixed recurrent state.

(a) Show that for some scalars c and γ, with c > 0 and 0 < γ < 1, we have

P(X1 6= s, . . . , Xn 6= s |X0 = i) ≤ cγn

for all i and n ≥ 1.

(b) Show that for all i 6= s, we have

µi ≤c

(1− γ)2,

where µi is the mean first passage time to go from a state i 6= s to state s.

(c) Show that the µi are the unique solution of the system of equations

µi = 1 +

m∑

j=1j 6=s

pijµj , for all i 6= s.

Solution. (a) For notational convenience, denote

qi(n) = P(X1 6= s, . . . , Xn 6= s |X0 = i).

Note that qi(n) is monotonically nonincreasing with n, and that qi(m) < 1, since byassumption, state s is accessible from each state i. Let

β = maxi=1,...,m

qi(m).

We have for all i, qi(m) ≤ β < 1, and also

qi(2m) = P(X1 6= s, . . . ,Xm 6= s, Xm+1 6= s, . . . ,X2m 6= s |X0 = i)

= P(X1 6= s, . . . ,Xm 6= s |X0 = i)

· P(Xm+1 6= s, . . . ,X2m 6= s |X0 = i, X1 6= s, . . . ,Xm 6= s)

≤ β2,

where the last relation follows from the calculation

P(Xm+1 6= s, . . . ,X2m 6= s |X0 = i, X1 6= s, . . . , Xm 6= s)

=∑

j 6=s

P(Xm = j |X0 = i, X1 6= s, . . . , Xm−1 6= s)

· P(Xm+1 6= s, . . . ,X2m 6= s |X0 = i, X1 6= s, . . . , Xm−1 6= s,Xm = j)

=∑

j 6=s

P(Xm = j |X0 = i, X1 6= s, . . . , Xm−1 6= s)

· P(Xm+1 6= s, . . . ,X2m 6= s |Xm = j)

≤∑

j 6=s

P(Xm = j |X0 = i, X1 6= s, . . . , Xm−1 6= s) · β

≤ β.

Page 384: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 55

Similarly, we show that for all i and k,

qi(km) ≤ βk.

Let n be any positive integer, and let k be the integer such that km ≤ n <(k + 1)m. Then, we have

qi(n) ≤ qi(km) ≤ βk = β−1(β1/m

)(k+1)m ≤ β−1(β1/m

)n.

Thus, the desired relation holds with c = β−1 and γ = β1/m.

(b) We have

µi =

∞∑

n=1

nP(X1 6= s, . . . , Xn−1 6= s, Xn = s |X0 = i)

≤∞∑

n=1

nqi(n − 1)

≤∞∑

n=1

ncγn−1

=c

1− γ

∞∑

n=1

n(1− γ)γn−1

=c

(1− γ)2,

where the last relation holds using the expression for the mean of the geometric distri-bution.

(c) That the µi are a solution to the given equations follows by applying the totalexpectation theorem. To show uniqueness, let µi be another solution. Then we havefor all i 6= s

µi = 1 +∑

j 6=s

pijµj , µi = 1 +∑

j 6=s

pijµj ,

and by subtraction, we obtain

δi =∑

j 6=s

pijδj,

where δi = µi − µi. By applying m successive times this relation, if follows that

δi =∑

j1 6=s

pij1

j2 6=s

pj1j2 · · ·∑

jm 6=s

pjm−1jm · δjm .

Hence, we have for all i 6= s

|δi| ≤

∣∣∣∣∣∣

j1 6=s

pij1

j2 6=s

pj1j2 · · ·∑

jm 6=s

pjm−1jm

∣∣∣∣∣∣· |δjm |

= qi(m) · |δjm |≤ β ·max

j 6=s|δj |.

Page 385: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

56 Markov Chains Chap. 6

The above relation holds for all i 6= s, so we obtain

maxj 6=s

|δj | ≤ β ·maxj 6=s

|δj|,

which implies that maxj 6=s |δj| = 0 or µj = µj for all j 6= s.

Problem 17. * Balance Equations and Mean Recurrence Times. Considera Markov chain with a single recurrent class. For any two states i and j, with j beingrecurrent, let

ρij = E[Number of visits to i between two successive visits to j

],

where by convention, ρjj = 1.

(a) Fix a recurrent state s. Show that the scalars

πi =ρis

t∗s, i = 1, . . . ,m,

satisfy the balance equations, where t∗s is the mean recurrence time of s (thexpected number of transitions up to the first return to s, starting from s.

(b) Show that if (π1, . . . , πm) satisfy the balance equations, then

πi =

1

µiif i is recurrent,

0 if i is transient,

where µi is the mean recurrence time of i.

(c) Show that the distribution of part (a) is the unique probability distribution thatsatisfies the balance equations.

Solution. (a) We first assert that

ρis =

∞∑

n=1

P(X1 6= s, . . . , Xn−1 6= s, Xn = i |X0 = s).

To see this, note that

ρis = E

[ ∞∑

n=1

In

∣∣∣ X0 = s

].

where In is the random variable that takes the value 1 if X1 6= s, . . . , Xn−1 6= s, andXn = i, and the value 0 otherwise, so that

E[In |X0 = s

]= P(X1 6= s, . . . , Xn−1 6= s, Xn = i 6= s |X0 = s).

We next use the total probability theorem to write for n ≥ 2

P(X1 6= s, . . . ,Xn−1 6= s, Xn = i |X0 = s)

=∑

k 6=s

P(X1 6= s, . . . , Xn−2 6= s, Xn−1 = k |X0 = s)pki.

Page 386: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 57

We thus obtain

ρis = E

[ ∞∑

n=1

In

∣∣∣ X0 = s

]

= psi +

∞∑

n=2

P(X1 6= s, . . . , Xn−1 6= s, Xn = i |X0 = s)

= psi +

∞∑

n=2

k 6=s

P(X1 6= s, . . . ,Xn−2 6= s, Xn−1 = k |X0 = s)pki

= psi +∑

k 6=s

pki

∞∑

n=2

P(X1 6= s, . . . ,Xn−2 6= s,Xn−1 = k |X0 = s)

= ρsspsi +∑

k 6=s

pkiρks

=

m∑

k=1

ρkspki.

Dividing both sides of this relation by t∗s, we obtain

πi =

m∑

k=1

πkpki,

where πi = ρis/t∗s. Thus, the πi solve the balance equations. Furthermore, the πi arenonnegative, and we clearly have

∑m

i=1ρis = t∗s or

∑m

i=1πi = 1. Hence, (π1, . . . , πm)

is a probability distribution.

(b) Consider a probability distribution (π1, . . . , πm) that satisfies the balance equations.Fix a recurrent state s, let t∗s be the mean recurrence time of s, and let ti be the meanfirst passage time from a state i 6= s to state s. We will show that πst

∗s = 1. Indeed,

we havet∗s = 1 +

j 6=s

psjtj,

ti = 1 +∑

j 6=s

pijtj , for all i 6= s.

Multiplying these equations with πs and πi, respectively, and adding, we obtain

πst∗s +

i 6=s

πiti = 1 +

m∑

i=1

πi

j 6=s

pijtj .

By using the balance equations, the right-hand side is equal to

1 +

m∑

i=1

πi

j 6=s

pij tj = 1 +∑

j 6=s

tj

m∑

i=1

πipij = 1 +∑

j 6=s

tjπj.

Page 387: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

58 Markov Chains Chap. 6

By combining the last two equations, we obtain πst∗s = 1.

Since the probability distribution (π1, . . . , πm) satisfies the balance equations, ifthe initial state X0 is chosen according to this distribution, all subsequent states Xn

have the same distribution. If we start at a transient state i, the probability of beingat that state at time n diminishes to 0 as n →∞. It follows that we must have πi = 0.

(c) Part (a) shows that there exists at least one stationary probability distribution.Part (b) shows that there can be only one stationary probability distribution.

Problem 18. * Steady-State Convergence. Consider a Markov chain with a singlerecurrent class, and assume that there exists a special recurrent state s and a time nsuch that s can be reached in n steps starting from any state:

ris(n) > 0, i = 1, . . . ,m.

(a) Show that there exists a time n such that for all i = 1, . . . ,m, all recurrent j,and all n ≥ n, we have

rij(n) > 0.

Furthermore, the recurrent class of the chain is aperiodic.

(b) Show that for all i and j, we have

limn→∞

rij(n) = πj,

where the πj are the unique solution of the balance equations (cf. the precedingproblem). In particular, there exist scalars c and γ with c > 0 and 0 < γ < 1such that for all n, i, and j, we have

∣∣rij(n) − πj

∣∣ ≤ cγn.

Solution. (a) We first claim that for all i, we have

ris(n) > 0, for all n ≥ n.

This follows by induction. In particular, if ris(n) > 0 for all i, we have

ris(n + 1) =

m∑

j=1

pijrjs(n) ≥ mini=1,...,m

rjs(n) > 0, for all i.

We next note that for all j that are reachable from s in k steps, we have rij(n+ k) > 0for all i, as long as ris(n) > 0 for all i. Hence, we have rij(n) > 0 for all i and alln ≥ n + k. Since all recurrent states j are reachable from s within m − 1 steps, wehave rij(n) > 0 for all i and j, and all n ≥ n + m − 1. This also shows that the chainis aperiodic.

(b) For all states i and all transient states j, we have

rij(n) = P(Xn = j |X0 = i) ≤ P(X1 : transient, . . . ,Xn : transient |X0 = i).

Page 388: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 59

Hence rij(m) < 1, and by using an argument similar to the one used to prove finitenessof the first passage time in chains with a single recurrent class [cf. Problem 3(a)], weobtain rij(n) ≤ cγn for all n, where c and γ are some scalars with c > 0 and 0 < γ < 1.Thus, |rij(n) − πj| ≤ cγn for all n.

We introduce a copy of the given Markov chain and denote its state at time nby Yn. We start the given chain at some fixed initial state X0 = i and we select theinitial state Y0 according to its unique solution of the balance equations. Let T be thefirst time n for which we have Xn = Yn:

T = minn |Xn = Yn.

Fix a recurrent state j. We have

rij(n) = P(Xn = j) = P(Xn = j, n ≥ T ) + P(Xn = j, n < T ),

πj = P(Yn = j) = P(Yn = j, n ≥ T ) + P(Yn = j, n < T ).

By subtracting these two equations and taking the absolute value of both sides,

|rij(n)− πj | ≤∣∣P(Xn = j, n ≥ T ) −P(Yn = j, n ≥ T )

∣∣+

∣∣P(Xn = j, n < T )−P(Yn = j, n < T )∣∣

≤∣∣P(Xn = j, n < T ) −P(Yn = j, n < T )

∣∣≤ P(n < T ),

where the last inequality follows using the generic relation

|P(B ∩A) −P(C ∩ A)| ≤ P(A), for any events A, B,C.

We now introduce for every n the probability qi(n) that Xk and Yk are notsimultaneously equal to state j for any k ≤ n:

qi(n) = P(∩n

k=1

(Xk 6= j ∪ Yk 6= j

)).

We have qi(n) < 1 since by part (a), j is reachable from all states in at most n steps,and by using again an argument similar to the one used in Problem 3(a), we obtainqi(n) ≤ cγn for all n, where c and γ are some scalars with c > 0 and 0 < γ < 1. Onthe other hand, we have for all n,

|rij(n)− πj | ≤ P(n < T ) ≤ qi(n),

so |rij(n)− πj | ≤ cγn for all n.

Problem 19. * Expected Long-Term Frequency Interpretation. Consider aMarkov chain with a single recurrent class that satisfies the condition of the precedingproblem. Show that

πj = limn→∞

vij(n)

n, for all i, j = 1, . . . ,m,

Page 389: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

60 Markov Chains Chap. 6

where πj are the steady-state probabilities, and vij(n) is the expected value of thenumber of visits to state j within the first n transitions, starting from state i.

Solution. We first assert that for all n, i, and j, we have

vij(n) =

n∑

k=1

rij(k).

To see this, note that

vij(n) = E

[n∑

k=1

Ik

∣∣∣ X0 = i

],

where Ik is the random variable that takes the value 1 if Xk = j, and the value 0otherwise, so that

E[Ik |X0 = i

]= rij(k).

From Problem 6(b), we have that there exist scalars c and γ, with c > 0 and 0 < γ < 1,such that for all n, i, and j, we have

∣∣rij(n)− πj

∣∣ ≤ cγn.

Hence ∣∣∣∣vij(n)

n− πj

∣∣∣∣ =

∣∣∣∣∣

∑n

k=1

(rij(k)− πj

)

n

∣∣∣∣∣

≤ c

∣∣∣∣∑n

k=1γk

n

∣∣∣∣

≤ cγ

n(1− γ).

This proves the desired result.

Problem 20. * Absorption Probabilities. Consider a Markov chain where eachstate is either transient or absorbing. Fix an absorbing state s. Show that the proba-bilities ai of eventually reaching s starting from a state i are the unique solution of theequations

as = 1,

ai = 0, for all absorbing i 6= s,

ai =

m∑

j=1

pijaj , for all transient i.

Solution. By the total probability theorem, the ai are a solution to the given equations.To show uniqueness, let ai be another solution, and let δi = ai − ai. Denoting by Athe set of absorbing states and using the fact δj = 0 for all j ∈ A, we have

δi =

m∑

j=1

pijδj =∑

j /∈A

pijδj , for all transient i.

Page 390: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 61

Applying this relation m successive times, we obtain

δi =∑

j1 /∈A

pij1

j2 /∈A

pj1j2 · · ·∑

jm /∈A

pjm−1jm · δjm .

Hence

|δi| ≤

∣∣∣∣∣∣

j1 6=s

pij1

j2/∈A

pj1j2 · · ·∑

jm /∈A

pjm−1jm

∣∣∣∣∣∣· |δjm |

= P(X1 /∈ A, . . . , Xm /∈ A |X0 = i) · |δjm |≤ P(X1 /∈ A, . . . , Xm /∈ A |X0 = i) ·max

j /∈A|δj|.

The above relation holds for all i 6= s, so we obtain

maxj /∈A

|δj | ≤ β ·maxj /∈A

|δj|,

whereβ = P(X1 /∈ A, . . . ,Xm /∈ A |X0 = i).

Since β < 1, it follows that maxj /∈A |δj | = 0 or ai = ai for all i that are not absorbing.We also have aj = aj for all absorbing j, so ai = ai for all i.

Problem 21. * Multiple Recurrent Classes. Consider a Markov chain that hasmore that one recurrent classes, as well as some transient states. Assume that all therecurrent classes are aperiodic.

(a) For any transient state i, let ai(k) be the probability that starting from i wewill reach a state in the kth recurrent class. Derive a system of equations whosesolution are the ai(k).

(b) Show that each n-step transition probabilities rij(n) converges to a limit denotedπij. Derive a system of equations whose solution are the πij.

Solution. (a) We introduce a new Markov chain that has only transient and absorbingstates. The transient states correspond to the transient states of the original, whilethe absorbing states correspond to the recurrent classes of the original. The transitionprobabilities pij of the new chain are as follows: if i and j are transient, pij = pij; if i isa transient state and j corresponds to a recurrent class, pij is the sum of the transitionprobabilities from i to states in the recurrent class in the original Markov chain.

The desired probabilities ai(k) are the absorption probabilities in the new Markovchain and are given by the corresponding formulas:

ai(k) = pik +∑

j:transient

pijaj(k), for all transient i.

(b) If i and j are recurrent but belong to different classes, again rij(n) converges to 0.If i and j are recurrent but belong to the same class, rij(n) converges to the steady-state probability of j conditioned on the initial state being in the class of j. If j istransient, rij(n) converges to 0. Finally, if i is transient and j is recurrent, then rij(n)

Page 391: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

62 Markov Chains Chap. 6

converges to the product of two probabilities: (1) the probability that starting from iwe will reach a state in the recurrent class of j, and (2) the steady-state probability ofj conditioned on the initial state being in the class of j.

SECTION 6.5. More General Markov Chains

Problem 22. Persons arrive at a taxi stand with room for five taxis according toa Poisson process with rate one per minute. A person boards a taxi upon arrival ifone is available and otherwise waits in a line. Taxis arrive at the stand according toa Poisson process with rate two per minute. An arriving taxi that finds the stand fulldeparts immediately; otherwise, it picks up a customer if at least one is waiting, or elsejoins the queue of waiting taxis. What is the steady-state probability distribution ofthe taxi queue size?

Solution. Consider a continuous-time Markov chain with state

n = Number of people waiting + number of empty taxi positions.

Then the state goes from n to n + 1 each time a person arrives and goes from n ton − 1 (if n ≥ 1) when a taxi arrives. Thus the system behaves like an M/M/1 queuewith arrival rate 1 per min and departure rate 2 per min. Therefore the occupancydistribution is

πn =(1− ρ)

ρn,

where ρ = 1/2. State n, for 0 ≤ n ≤ 4 corresponds to 5, 4, 3, 2, 1 taxis waiting whilen > 4 corresponds to no taxi waiting. Therefore

P(5 taxis waiting) = 1/2,

P(4 taxis waiting) = 1/4,

P(3 taxis waiting) = 1/8,

P(2 taxis waiting) = 1/16,

P(1 taxi waiting) = 1/32.

and P(no taxi waiting) is obtained by subtracting the sum of the probabilities abovefrom unity. This gives P(no taxi waiting) = 1/32.

Problem 23. Empty taxis pass by a street corner at a Poisson rate of two perminute and pick up a passenger if one is waiting there. Passengers arrive at the streetcorner at a Poisson rate of one per minute and wait for a taxi only if there are lessthan four persons waiting; otherwise they leave and never return. Find the expectedwaiting time of a passenger that joins the queue.

Solution. We consider a continuous-time Markov chain with state n = 0, 1, . . . , 4,where

n = Number of people waiting.

The transitions from n to n + 1 have rate 1, and the transitions from n + 1 to n haverate 2. The balance equations are

πn =πn−1

2, n = 1, . . . , 4.

Page 392: 1 Sample Space and Probability - National Chiao Tung …web.it.nctu.edu.tw/~chungliu/courses/StochasticProcesses/notes/... · 2 Sample Space and Probability Chap. 1 “Probability”

Sec. 6.5 More General Markov Chains 63

Solving these equations together with the normalization equation∑4

i=0πi = 1, we find

πn =24−n

3!, n = 0, 1, . . . , 4.

A customer that joins the queue will find n customers ahead of him where n = 0, 1, 2, 3with steady-state probabilities πn/(π0 + π1 + π2 + π3). The expected number of cus-tomers found by an arriving customer who joins the queue is

E[N ] =π1 + 2π2 + 3π3

π0 + π1 + π2 + π3.

Since the expected waiting time for a new taxi is 1/2 minute, the expected waitingtime, by the law of iterated expectations is

E[T ] = E[N ]1

2.

Problem 24. An athletic facility has 5 tennis courts. Players arrive at the courtsaccording to a Poisson process with rate of one pair per 10 minutes, and use a courtfor an exponentially distributed time with mean 40 minutes. Suppose a pair of playersarrives and finds all courts busy and k other pairs waiting in queue. What is theexpected waiting time to get a court?

Solution. When all the courts are busy, the expected time between two departures is40/5 = 8 minutes. If a pair sees k pairs waiting in the queue, there must be exactlyk+1 departures from the system before they get a court. Since all the courts would bebusy during this whole time, the expected waiting time required before k+1 departuresis 8(k + 1) minutes.

Problem 25. A facility of m identical machines is sharing a single repairperson. Thetime to repair a failed machine is exponentially distributed with mean 1/λ. A machineonce operational, fails after a time that is exponentially distributed with mean 1/µ.All failure and repair times are independent. What is the steady-state proportion oftime where there is no operational machine?

Solution. Define the state to be the number of operational machines. This results in acontinuous-time Markov chain, which is the same as an M/M/1 queue with arrival rateλ and service rate µ, except that there is storage for any m customers. The requiredprobability is simply π0 for this queue.