Tutorial 4 Solution
Tutorial 4 Solution
n
p X (k ) p k (1 − p )
n−k
=
k
pM ( k )= (1 − p )
k −1
1 1− p
E [M ] =
p
VAR[ M ] = 2
p p
1
pX ( k ) = M −1 M 2 −1
M E[ X ] = VAR[ X ] =
2 12
αk
pN ( k ) = e −α
k!
Conditional Probability Mass Function
3
The conditional probability mass function of X given C is
P[( X= x) ∩ C ]
pX ( x =
| C ) P=
[ X x=| C]
P[C ]
S
Properties of conditional PMF
Ak
pX ( x | C ) ≥ 0 C
X (ζ ) = xk
xk
∑ p (x | C) ∑
( X = xk ) ∩ C
= X = p (x | C) X k 1
x∈S X all k
P [ X in B | C ] ∑ p ( x | C ) where B ⊂ S
X X
x∈B
E[ X ] = ∑ E[ X Bi ]P[ Bi ]
i
= E[ X 2 B] − mX2 B
Example 1 - Conditional Poker Hand
The cat has already got the cards: 4, 5, 6, 7, 8 (all are spades). The
president will draw 5 cards from the remaining 47 ones. Then:
(a) What is the sample space S of the poker hand which the president
may get to beat the cat?
(b) What is the chance that the president can beat the cat?
Oh Yeah!
Example 1 - Conditional Poker Hand Solution
Solution
(a) All the possible poker hand which can beat the cat are as follows:
Spades: (9,10,J,Q,K), (10,J,Q,K,A)
Hearts: (5,6,7,8,9), (6,7,8,9,10), (7,8,9,10,J), (8,9,10,J,Q), (9,10,J,Q,K),
(10,J,Q,K,A)
Clubs: (5,6,7,8,9), (6,7,8,9,10), (7,8,9,10,J), (8,9,10,J,Q), (9,10,J,Q,K),
(10,J,Q,K,A)
Diamonds: (5,6,7,8,9), (6,7,8,9,10), (7,8,9,10,J), (8,9,10,J,Q),
(9,10,J,Q,K), (10,J,Q,K,A)
The sample space S is the set of all possible outcomes.
6
Example 1 - Conditional Poker Hand Solution
(b)
7
Example 2
Consider a manufacturing plant producing electronic devices. The
devices are made cheaply; therefore each device on the production
line fails the quality inspection with probability 0.1. Assume that 20
devices are selected from this production line at random. X is the
number of selected products failing inspection.
1. Compute the mean and variance of X.
2. Consider the relation: Y = 2X + 3. Find the expected value and
variance of Y.
Solution
1. X is a binomial R.V
n = 20, p = 0.1
E [ X ] = np = 20 × 0.1 = 2 Var [Y ] = np (1 − p ) = 20 × 0.1× (1 − 0.1) = 1.8
2. E [Y ] = E [ 2 X + 3] = 2 E [ X ] + 3 = 2 × 2 + 3 = 7
Var[Y ] =Var [ 2 X + 3] =4Var [ X ] + Var [3] =4 ×1.8 =7.2
8
Example 3
The number of page request that arrive at a Web server is a Poisson RV
with average of 3000 requests per minute.
(a) Find the probability that there are no requests in a 100 ms period.
(b) Find the probability that there are between 5 and 10 requests in a
100 ms period.
9
Example 3-Solution
10
Example 4
You go to a party with 500 guests (i.e. there are totally 500 people at
the party including yourself). What is the probability that exactly one
other guest has the same birthday as you? Calculate this probability
exactly and also approximately by using the Poisson pmf. (You may
assume that there are 365 days in every year and the birthday dates are
distributed with equal probabilities throughout the year.)
11
Example 4 - Solution
Solution
The number of guests that have the same birthday as you is binomial
with p =1/365 and n = 499. Thus the probability that exactly one other
guest has the same birthday is
12
Example 5
Suppose that we have two types of visitors to a store, B1 and B2.
Statistics shows that 40 percent of the visitors are type B1, and 60
percent are type B2. Let X be the amount (in dollars) spent by a visitor.
The money spent by B1 visitors are drawn from the set {0, 1, 2, 3, 4,
5, 6, 7, 8, 9} with equal probability. And the money spent by B2
visitors are drawn from the set {0, 1, 2, 3, 4} with equal probability.
Find the pmf of X, as well as its mean and variance.
13
Example 5 - Solution
14
Example 6
Denote the number of customers who arrive at the HKUST café during
the lunch time on a day as 𝑁𝑁. Assume on weekdays (from Monday to
Friday), 𝑁𝑁 is a Poisson random variable with mean 𝛼𝛼1 = 400; while
on weekends (Saturday and Sunday), 𝑁𝑁 is a Poisson random variable
with mean 𝛼𝛼2 = 200.
(a) Define the event 𝐸𝐸1 as “the day is a weekday”. Given 𝐸𝐸1 happens,
find the conditional pmf of 𝑁𝑁, i.e., 𝑝𝑝𝑁𝑁 (𝑛𝑛|𝐸𝐸1 ).
(b) Define the event 𝐸𝐸2 as “the day is the weekend”. Given 𝐸𝐸2 happens,
find the conditional pmf of 𝑁𝑁, i.e., 𝑝𝑝𝑁𝑁 (𝑛𝑛|𝐸𝐸2 )
(c) Based on the results of a) and b), find the pmf of 𝑁𝑁, i.e., 𝑝𝑝𝑁𝑁 (𝑛𝑛).
(d) What is the mean of 𝑁𝑁, i.e., E[𝑁𝑁]?
(e) What is the variance of 𝑁𝑁, i.e., VAR[𝑁𝑁]?
15
Example 6 - Solution
𝛼𝛼1𝑛𝑛 −𝛼𝛼 400𝑛𝑛 −400
(a) 𝑝𝑝𝑁𝑁 𝑛𝑛 𝐸𝐸1 = 𝑒𝑒 1 = 𝑒𝑒 , 𝑛𝑛 = 0, 1, 2, …
𝑛𝑛! 𝑛𝑛!
𝛼𝛼2𝑛𝑛 −𝛼𝛼 200𝑛𝑛 −200
(b) 𝑝𝑝𝑁𝑁 𝑛𝑛 𝐸𝐸2 = 𝑒𝑒 2 = 𝑒𝑒 , 𝑛𝑛 = 0, 1, 2, …
𝑛𝑛! 𝑛𝑛!
400𝑛𝑛 −400 5
(c) 𝑝𝑝𝑁𝑁 𝑛𝑛 = 𝑝𝑝𝑁𝑁 𝑛𝑛 𝐸𝐸1 P 𝐸𝐸1 + 𝑝𝑝𝑁𝑁 𝑛𝑛 𝐸𝐸2 P 𝐸𝐸2 = 𝑒𝑒 × +
𝑛𝑛! 7
200𝑛𝑛 −200 2
𝑒𝑒 × , 𝑛𝑛 = 0, 1, 2, …
𝑛𝑛! 7
(d) E 𝑁𝑁 = E 𝑁𝑁 𝐸𝐸1 P 𝐸𝐸1 + E 𝑁𝑁 𝐸𝐸2 P 𝐸𝐸2 = 𝛼𝛼1 × P 𝐸𝐸1 + 𝛼𝛼2 ×
5 2 2400
P 𝐸𝐸2 = 400 × + 200 × = ≈ 342.8571
7 7 7
(e)E 𝑁𝑁 2 𝐸𝐸1 = VAR 𝑁𝑁 𝐸𝐸1 + E 𝑁𝑁 𝐸𝐸1 2 = 𝛼𝛼1 + 𝛼𝛼12 = 160400
E 𝑁𝑁 2 𝐸𝐸2 = VAR 𝑁𝑁 𝐸𝐸2 + E 𝑁𝑁 𝐸𝐸2 2 = 𝛼𝛼2 + 𝛼𝛼22 = 40200
E 𝑁𝑁 2 = E 𝑁𝑁 2 𝐸𝐸1 P 𝐸𝐸1 + E 𝑁𝑁 2 𝐸𝐸2 P 𝐸𝐸2
2
5 2
2
= (𝛼𝛼1 +𝛼𝛼1 ) × + (𝛼𝛼2 +𝛼𝛼2 ) × ≈ 1.2606 × 105
7 7
VAR 𝑁𝑁 = E 𝑁𝑁 2 − E 𝑁𝑁 2 ≈ 8.5061 × 103
16
MATLAB Example
Denote X the binomial random variable with parameters n=15 and
p=0.2. Plot the pmf of 𝑋𝑋 and generate 50,000 samples of X by using
MATLAB.
Solution: 0.35
n = 15; 0.3
p = 0.2;
xmin = 0; % minimum limit of plot 0.25
'MarkerFaceColor','g',...
'MarkerSize',10); 0
0 5 10 15
17
MATLAB Example
n = 15;
p = 0.2;
mm = 1; % size of array of samples (Rows)
nn = 50000; % size of array of samples (Columns)
y = binornd(n,p,mm,nn); % generate samples
figure(2);
P=hist(y,0:1:15)/50000; %normalized histogram of y
bar(0:1:15,P)
0.35
0.3
0.25
0.2
0.15
0.1
0.05
0
-5 0 5 10 15 20
18