CSIS 1118B Mathematical foundation for Computer Science — Sample Solution for Assignment Five Q1. Answer: X(s)+Y(s) = max{X(s),Y(s)}+min{X(s),Y(s)}. Since Z(s) = max{X(s),Y(s)} and min{X(s),Y(s)}≥0, X(s)+Y(s) = Z(s)+min{X(s),Y(s)}≥ Z(s)
E ( X ) = ∑ X ( s) p( s ) , E (Y ) = ∑ Y ( s ) p ( s ) , E ( Z ) = ∑ Z ( s) p( s) .
s∈S
s∈S
s∈S
E ( X ) + E (Y ) = ∑ X (s) p(s) + ∑Y (s) p(s) = ∑ ( X (s) + Y (s)) P(s) ≥ ∑ Z ( s ) P( s ) = E ( Z )
s∈S s∈S s∈S s∈S
Comments: some students solve this problem in many cases. However, they only consider the case that X(s) ≥Y(s) or X(s) ≤Y(s) for all the sample elements in the sample space. The case that for some sample elements s in S such that X(s) ≥Y(s) and t in S such that X(t) ≤Y(t) should also be discussed.. Q2 Answer: According to the definition of variance:
V ( x1 + x2 + L + xn ) = E ( x1 + x2 + L + xn ) 2 − ( E ( x1 + x2 + L + xn )) 2 = E ( x12 + x2 2 + L + xn 2 + 2
1≤i < j ≤ n
∑
xi x j )
−[ E ( x1 )]2 − [ E ( x2 )]2 − L − [ E ( xn )]2 −2
1≤i < j ≤ n
∑
E ( xi ) E ( x j )
= {E ( x12 ) − ( E ( x1 )) 2 } + {E ( x2 2 ) − ( E ( x2 ))2 } + L +2{
1≤i < j ≤ n
∑
( E ( xi ) E ( x j ) − E ( xi ) E ( x j ))}
Since xi and x j are pairwise independent, E ( xi x j ) = E ( xi ) E ( x j ) .
V ( x1 + x2 + L + xn ) = {E ( x12 ) − ( E ( x1 )) 2 } + {E ( x2 2 ) − ( E ( x2 ))2 } + L +2{
1≤i < j ≤ n
∑
( E ( xi ) E ( x j ) − E ( xi ) E ( x j ))}
= V ( x1 ) + V ( x2 ) + L + V ( xn )
Q3. Answer:
(Strategy I )Assume that a, b be the numbers sealed in the envelopes. Without loss of generality, assume a > b. With probability 1/2 , the number r that we peek in step (a) is equal to a (the bigger number in the envelope). In this case, the strategy wins if a ≥ 5. With probability 1/2, the number r that we peek in step (a) is equal to b. The strategy wins if b < 5. P ( wins ) = P ( a ≥ 5 | r = a ) P ( r = a ) + P (b ≤ 5 | r = b) Consider different cases: 1) a > b≥5, . P ( wins ) = P(a ≥ 5 | r = a ) P(r = a ) + P(b ≤ 5 | r = b) 1 1 1 = 1× + 0 × = 2 2 2 2) 5>a > b, P ( wins ) = P(a ≥ 5 | r = a ) P(r = a ) + P(b ≤ 5 | r = b) 1 1 1 = 0 × + 1× = 2 2 2 3)a ≥5, b<5, P ( wins ) = P(a ≥ 5 | r = a ) P(r = a ) + P(b ≤ 5 | r = b) 1 1 = 1 × + 1× = 1 2 2 Therefore, strategy I does not have a better than 50% chance of winning for some cases of the two distinct integers chosen, e.g. both integers chosen are less than 5. (Strategy II) Assume that a, b be the numbers sealed in the envelopes. Without loss of generality, assume a > b With probability 1/2 , the number r that we peek in step (a) is equal to a (the bigger number in the envelope). In this case, the strategy wins if a ≥ 5. With probability 1/2, the number r that we peek in step (a) is equal to b. The strategy wins if b < 5. P( wins ) = P ( x < a | r = a) P(r = a ) + P( x > b | r = b) a 1 10 − b 1 1 a − b 1 = × + × = + > 10 2 10 2 2 20 2 Since a>b. Therefore, strategy II has a better than 50% chance of winning no matter which two distinct integers have been chosen in advance. Comments: Many students make mistakes for this question. Two numbers have been chosen in advance. You are required to calculate the probability of winning no matter which
numbers are selected. For example when a=4, b=3, calculate the probability of winning. Compare the two strategies no matter which two distinct integers have been sealed in advance. Some marks are deducted. Q4 Answer: Assume X to be the random variable for the number of cans of soda pop filled in a day at a plant. We need to calculate: P (9000 < X < 11000) . P (9000 < X < 11000) = P(−1000 < X − 10000 < 1000) = P ( X − 10000 < 1000) = 1 − P( X − 10000 ≥ 1000) P( X − 10000 ≥ 1000) ≤ 1000 = 0.001 (Chebyshev’s Inequality) (1000) 2
P (9000 < X < 11000) = P(−1000 < X − 10000 < 1000) = P ( X − 10000 < 1000) = 1 − P( X − 10000 ≥ 1000) ≥ 1 − 0.001 = 0.999 Q5 Answer: Assume that X is the random variable for the number of people who get back their hat correctly. As for each person Xi Xi=1 when the i person gets back his hat correctly and Xi=0 when i person gets back his hat incorrectly. X = ∑ xi .
i =1 n
As for each person, they get back their own hat with the probability 1/n. Then, E ( X ) = ∑ E ( xi ) = ∑
i =1 i =1 n n
1 =1 n
V ( X ) = E ( X 2 ) − ( E ( X )) 2 = E ( x1 + x 2 + L + x n ) 2 − 1
2 2 = E ( x12 + x 2 + L + x n + 2
1≤ i < j ≤ n
∑
xi x j ) − 1 E ( xi x j ) − 1 −1
2 2 = E ( x12 + x 2 + L + x n ) + 2
1≤ i < j ≤ n
∑
= 1+ 2
the number for E ( xi x j )
( n − 1) n 1 23 424
×
the exp ectation for i and j get his hat back correctly
( n − 2)! 1 n !3 424
=1
P( X > 10) = P( X ≥ 11) = P( X −1 ≥ 10) ≤ P( X −1 ≥ 10) ≤ 1 100
It can be concluded that no matter how many people check their hat, the probability of more than 10 people get back their hats correctly is less than 1/100. Comments: As for this question, some students calculate the variance of X as n − 1 . However,
n
xi and x j are not independent. Suppose that there are n people checking their hats. If n-1 people have had their hats back correctly, the last one must get his back correctly. This question is very similar to the “Fix points ” problem in lecture notes and also similar to the optional question in assignment 4. Some marks are deducted. Q6: Answer: (a) There is no Euler circuit since the graph does not have all vertices of even degree. There is also no Euler path since the graph does not have exactly two vertices of odd degree. (b) There is Euler circuit: a,b,d,e,b,c,f,e,h,f,i,h,g,d,a. (c) There is no Euler circuit. There are two vertices i.e. a,d of odd degree. Therefore, there is Euler path.a,b,e,b,d,e,a,c,e,c,d. (d) There is no Euler circuit since c and f have odd degree. Therefore, the Euler path is: f,a,e,f,b,a,d,e,c,d,b,c. (e) There is Euler circuit: a,e,a,e,d,b,c,d,c,e,b,a. Comments: Some students do not give answer about (a) although it has no Euler circuit and Euler path. Some marks are deducted. Q7:Answer: (a) There is no Hamilton circuit. It is not guaranteed that every vertex is traversed only once. (b) There is Hamilton circuit a,b,c,d,e,a (c) There is no Hamilton circuit when you entered vertex f, There is no way to go out. (d) There is no Hamilton circuit since if all the vertices are traversed inside the small circle, d or b or h or f has to be visited at least twice. (e) There is no Hamilton circuit since if e or g or f are visited, there is no way to go out.