Documente Academic
Documente Profesional
Documente Cultură
Definitions
Discrete Random Variables
In this chapter and for most of the remainder of this book, we examine probability
models that assign numbers to the outcomes in the sample space.
In our notation, the name of a random variable is always a capital letter, for example,
X.
Since we often consider more than one random variable at a time, we denote the
range of a random variable by the letter S with a subscript that is the name of the
random variable.
The experiment is to test six integrated circuits and after each test ob-
serve whether the circuit is accepted (a) or rejected (r). Each observation
is a sequence of six letters where each letter is either a or r. For example,
s8 = aaraaa. The sample space S consists of the 64 possible sequences.
A random variable related to this experiment is N , the number of ac-
cepted circuits. For outcome s8, N = 5 circuits are accepted. The range
of N is SN = {0, 1, . . . , 6}.
Example 3.3
In Example 3.2, the net revenue R obtained for a batch of six integrated
circuits is $5 for each circuit accepted minus $7 for each circuit rejected.
(This is because for each bad circuit that goes out of the factory, it will
cost the company $7 to deal with the customers complaint and supply a
good replacement circuit.) When N circuits are accepted, 6 N circuits
are rejected so that the net revenue R is related to N by the function
{X = x} = {s S|X(s) = x} . (3.4)
Definition 3.2 Discrete Random Variable
SX = {x1, x2, . . .} .
Quiz 3.1
A student takes two courses. In each course, the student will earn either
a B or a C. To calculate a grade point average (GPA), a B is worth 3
points and a C is worth 2 points. The students GPA G2 is the sum of the
points earned for each course divided by 2. Make a table of the sample
space of the experiment and the corresponding values of the GPA, G2.
Quiz 3.1 Solution
The sample space, probabilities and corresponding grades for the experi-
ment are
Outcomes BB BC CB CC
G2 3.0 2.5 2.5 2.0
Section 3.2
PX (x) = P [X = x]
Example 3.5 Problem
When the basketball player Wilt Chamberlain shot two free throws, each
shot was equally likely either to be good (g) or bad (b). Each shot that
was good was worth 1 point. What is the PMF of X, the number of
points that he scored?
Example 3.5 Solution
There are four outcomes of this experiment: gg, gb, bg, and bb. A simple
tree diagram indicates that each outcome has probability 1/4. The sample
space and probabilities of the experiment and the corresponding values
of X are given in the table:
Outcomes bb bg gb gg
P[] 1/4 1/4 1/4 1/4
X 0 1 1 2
The random variable X has three possible values corresponding to three
events:
Each PMF display format has its uses. The function definition (3.8) is
best when PX(x) is given in terms of algebraic functions of x for various
subsets of SX . The bar plot is best for visualizing the probability masses.
The table can be a convenient compact representation when the PMF is
a long list of sample values and corresponding probabilities.
Theorem 3.1
(b) P[N = 1]
(c) P[N 2]
In each family, the probability mass functions of all the random variables have the
same mathematical form.
Depending on the family, the PMF formula contains one or two parameters.
Our nomenclature for a family consists of the family name followed by one or two
parameters in parentheses.
For example, binomial (n, p) refers in general to the family of binomial random
variables.
Binomial (7, 0.1) refers to the binomial random variable with parameters n = 7 and
p = 0.1.
Example 3.6
Consider the following experiments:
Flip a coin and let it land on a table. Observe whether the side facing up is heads
or tails. Let X be the number of heads observed.
Select a student at random and find out her telephone number. Let X = 0 if the
last digit is even. Otherwise, let X = 1.
Observe one bit transmitted by a modem that is downloading a file from the Inter-
net. Let X be the value of the bit (0 or 1).
Test one circuit and observe X, the number of rejects. What is PX(x)
the PMF of random variable X?
Example 3.7 Solution
Because there are only two outcomes in the sample space, X = 1 with
probability p and X = 0 with probability 1 p,
1 p x = 0,
PX (x) = p x = 1, (3.12)
0 otherwise.
Therefore, the number of circuits rejected in one test is a Bernoulli (p)
random variable.
Example 3.8 Problem
The events A and B are independent since the outcome of attempt l is not affected by
the previous l 1 attempts. Note that P[A] is the binomial probability of k 1 successes
(i.e., rejects) in l 1 trials so that
l 1
P [A] = pk1 (1 p)l1(k1)
. (3.16)
k1
Finally, since P[B] = p,
l 1
PL (l) = P [A] P [B] = pk (1 p)lk (3.17)
k1
L is an example of a Pascal random variable.
Definition 3.7 Pascal (k, p) Random Variable
Roll a fair die. The random variable N is the number of spots on the side
facing up. Therefore, N is a discrete uniform (1, 6) random variable with
PMF
0.2
PN(n) 1/6 n = 1, 2, 3, 4, 5, 6,
0.1 PN (n) =
0 otherwise.
(3.19)
0
0 5 n
Definition 3.9 Poisson () Random Variable
0
0 2 4 h
The probability of no hits is
P [H = 0] = PH (0) = (0.5)0 e0.5 /0! = 0.607. (3.20)
In an interval of 1 second, = T = (2 hits/s) (1 s) = 2 hits. Letting J denote the
number of hits in one second, the PMF of J is
PJ(j) 0.2
2j e2 /j!
j = 0, 1, 2, . . .
0.1 PJ (j) =
0 otherwise.
0
0 2 4 6 8 j
[Continued]
Example 3.13 Solution (Continued 2)
{J 2} = {J = 0} {J = 1} {J = 2} (3.21)
is the union of three mutually exclusive events. Therefore,
P [J 2] = P [J = 0] + P [J = 1] + P [J = 2]
= PJ (0) + PJ (1) + PJ (2)
= e2 + 21e2/1! + 22e2/2! = 0.677. (3.22)
Example 3.14
FX (x) = P [X x] .
Theorem 3.2
For any discrete random variable X with range SX = {x1, x2, . . .} satisfying
x1 x2 . . .,
(a) Going from left to right on the x-axis, FX(x) starts at zero and ends
at one.
(d) Between jumps, the graph of the CDF of the discrete random variable
X is a horizontal line.
Theorem 3.3
For all b a,
In Example 3.8, let the probability that a circuit is rejected equal p = 1/4.
The PMF of Y , the number of tests up to and including the first reject,
is the geometric (1/4) random variable with PMF
(1/4)(3/4)y1 y = 1, 2, . . .
PY (y ) = (3.25)
0 otherwise.
What is the CDF of Y ?
Example 3.16 Solution
Random variable Y has nonzero probabilities for all positive integers. For
any integer n 1, the CDF is
n n
1 3 j1
X X
FY (n) = P Y (j ) = . (3.26)
j=1 j=1 4 4
For one quiz, 10 students have the following grades (on a scale of 0 to
10):
9, 5, 10, 8, 4, 7, 5, 5, 8, 7 (3.31)
Find the mean, the median, and the mode.
Example 3.17 Solution
The sum of the ten grades is 68. The mean value is 68/10 = 6.8. The
median is 7, because there are four grades below 7 and four grades above
7. The mode is 5, because three students have a grade of 5, more than
the number of students who received any other grade.
Definition 3.11 Expected Value
The geometric (p) random variable X has expected value E[X] = 1/p.
Proof: Theorem 3.5
We observe that x/x! = 1/(x 1)! and also that the x = 0 term in the sum is zero. In
addition, we substitute x = x1 to factor from the sum to obtain
X x1
E [X] = e . (3.43)
x=1
(x 1)!
Next we substitute l = x 1, with the result
X l
E [X] = e = . (3.44)
l!
l=0
| {z }
1
We can
Pconclude that the sum in this formula equals 1 either by referring to the identity
l
e = l=0 /l! or by applying Theorem 3.1(b) to the fact that the sum is the sum of
the PMF of a Poisson random variable L over all values in SL and P[SL ] = 1.
Theorem 3.7
E [X ] = np.
E [X ] = k/p.
(c) For the discrete uniform (k, l) random variable X of Definition 3.8,
E [X ] = (k + l)/2.
Theorem 3.8
(c) The probability that four texts are received before a text is sent.
(1 p)r p r = 0, 1, 2 . . .
PR (r) = (3)
0 otherwise.
[Continued]
Quiz 3.5 Solution (Continued 2)
The probability of receiving four texts before sending a text is
PR (4) = (1 p)4 p. (4)
(d) The expected number of texts received before sending a text is
X
X
E [R] = rPR (r) = r(1 p)r p. (5)
r=0 r=0
A parcel shipping company offers a charging plan: $1.00 for the first
pound, $0.90 for the second pound, etc., down to $0.60 for the fifth
pound, with rounding up for a fraction of a pound. For all packages
between 6 and 10 pounds, the shipper will charge $5.00 per package. (It
will not accept shipments over 10 pounds.) Find a function Y = g(X)
for the charge in cents for sending one package.
Example 3.19 Solution
X=1
Y =100
.15
.15
X=2
Y =190
.15
X=3
Y =270
.15 X=4
X
H X
ZHXXX
@ Y =340
ZHH XXX
@Z H XXX
@Z HH
@Z
.10
H
X
X=5 Y =400
@ZZ HHH
.10
@ Z H
X=6XXXXX
.10
@ Z XX
@ ZZ XXX
.10@ Z X=7
X
X
Y =500
@
X=8
@@
N =0 M =900
0.4
N =1 M =1050
0.2
XXX
H
HHXXX
H XXX
HH XX
H 0.2 XXX N =2 M =1200
HH
H
0.2HHH
H N =3 M =1350
Given a random variable X with PMF PX(x) and the derived random
variable Y = g(X), the expected value of Y is
X
E [Y ] = Y = g(x)PX (x) .
xSX
Proof: Theorem 3.10
In Example 3.20,
1/4 x = 1, 2, 3, 4,
P X ( x) =
0 otherwise,
105X 5X 2 1 X 5,
g(X) =
500 6 X 10.
What is E[Y ] = E[g(X)]?
Example 3.22 Solution
E [X X ] = 0.
Proof: Theorem 3.11
E [aX + b] = a E [X ] + b.
Example 3.23 Problem
x = E [X ] .
Proof: Theorem 3.13
h i h i
2
Var [X ] = E X X = E X (E [X ])2 .
2 2
Proof: Theorem 3.14
x2PX(x) 2
X X X
Var[X] = 2X xPX(x) + X PX(x)
xSX xSX xSX
= E[X 2] 2X xPX(x) + 2
X X
X PX(x)
xSX xSX
= E[X 2] 22
X + 2.
X (3.71)
Definition 3.15 Moments
Continuing Examples 3.5, 3.18, and 3.23, we recall that X has PMF
0.5
1/4 x = 0,
PX(x)
1/2
x = 1,
PX (x) = (3.72)
1/4 x = 2,
0 0
otherwise,
1 0 1 2 3 x
and expected value E[X] = 1. What is the variance of X?
Example 3.25 Solution
In order of increasing simplicity, we present three ways to compute Var[X].
From Definition 3.13, define
W = (X X )2 = (X 1)2 . (3.73)
We observe that W = 0 if and only if X = 1; otherwise, if X = 0 or X = 2, then
W = 1. Thus P[W = 0] = PX(1) = 1/2 and P[W = 1] = PX(0) + PX(2) = 1/2. The
PMF of W is
1/2 w = 0, 1,
PW (w) = (3.74)
0 otherwise.
Then
Var [X] = E [W ] = (1/2)(0) + (1/2)(1) = 1/2. (3.75)
Recall that Theorem 3.10 produces the same result without requiring the derivation
of PW(w).
Var[X] = E (X X )2
2
Y = a2 2 + 2ab + b2 .
X x (3.81)
Because Var[Y ] = E[Y 2] 2
Y , Equations (3.80) and (3.81) imply that
h i h i
2
Var [Y ] = a E X a X = a (E X 2
2 2 2 2 2
X ) = a2 Var X .
[ ] (3.82)
Example 3.26 Problem
Note that U = 1000V . To use Theorem 3.15, we first find the variance
of V . The expected value of the amplitude is
Matlab
Matlab: Finite Random Variables
h i0
The output is y = y1 ym where yi = PX(xi).
That is, for each requested xi, finitepmf returns the value PX(xi).
Although
column vectors are supposed to appear as columns, we generally write a
0
column vector x in the form of a transposed row vector x1 xm to save space.
Example 3.28 Problem
px= ((alpha^x)*exp(-alpha*x))/factorial(x)
This will yield the right answer as long as the argument x for the factorial function is
not too large. In Matlab version 6, factorial(171) causes an overflow. In addition,
for a > 1, calculating the ratio ax /x! for large x can cause numerical problems because
both ax and x! will be very large numbers, possibly with a small quotient. Another
shortcoming of the direct calculation is apparent if you want to calculate PX(x) for
the set of possible values x = [0, 1, . . . , n]. Calculating factorials is a lot of work for
a computer and the direct approach fails to exploit the fact that if we have already
calculated (x 1)!, we can easily compute x! = x (x 1)!. [Continued]
Example 3.30 Solution (Continued 2)
A more efficient calculation makes use of the observation
ax ea a
PX (x) = = PX (x 1) . (3.88)
x! x
The poissonpmf.m function uses Equation (3.88) to calculate PX(x). Even this code is
not perfect because Matlab has limited range.
Let M equal the number of hits in one minute (60 seconds). Note that
M is a Poisson () random variable with = 2 60 = 120 hits. The
PMF of M is
(120)me120/m! m = 0, 1, 2, . . .
PM (m) = (3.89)
0 otherwise.
Rel. Freq.
Rel. Freq.
PY(y)
0 0 0
0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5
y y y
PMF PY (y) Sample Run 1 Sample Run 2
The PMF of Y and the relative frequencies found in two sample runs of
voltpower(100). Note that in each run, the relative frequencies are close
to (but not exactly equal to) the corresponding PMF.
Matlab: Derived Random Variables
For derived random variables, we exploit a feature of finitepmf(sx,px,x) that allows
the elements of sx to be repeated.
>> shipcostrv(9)
ans =
270 190 500 270 500 190 190 100 500
Quiz 3.9
function M=samplemean(k);
K=(1:k);
M=zeros(k,5);
for i=1:5,
X=duniformrv(0,10,k);
M(:,i)=cumsum(X)./K;
end;
plot(K,M);
10 10
8 8
6 6
4 4
2 2
0 0
0 50 100 0 500 1000