precept3sol

# precept3sol - Computer Science 340 Reasoning About...

• Homework Help
• PresidentHackerCaribou10582
• 6
• 100% (2) 2 out of 2 people found this document helpful

This preview shows pages 1–3. Sign up to view the full content.

Computer Science 340 Reasoning About Computation Precept 3 Problem 1 a) Prove that if X 1 and X 2 are independent random variables then E [ X 1 · X 2 ] = E [ X 1 ] E [ X 2 ]. b) Does E [ X 1 · X 2 ] = E [ X 1 ] E [ X 2 ] imply that X 1 and X 2 are independent random vari- ables? Solution: a) Let D 1 Z be the domain of X 1 and similarly D 2 be the domain of X 2 . According to the definition of expectation we know that: E [ X 1 ] E [ X 2 ] = i D 1 i · Pr[ X 1 = i ] j D 2 j · Pr[ X 2 = j ] = i D 1 j D 2 i · j · Pr[ X 1 = i ] · Pr[ X 2 = j ] Since X 1 , X 2 are independent we can proceed: = i D 1 j D 2 i · j · Pr[ X 1 = i ] · Pr[ X 2 = j | X 1 = i ] = i D 1 j D 2 i · j · Pr[ X 1 = i X 2 = j ] = t D 1 D 2 t · ( i,j ) D 1 × D 2 | i · j = t Pr[ X 1 = i X 2 = j ] = t D 1 D 2 t · Pr[ X 1 · X 2 = t ] = E [ X 1 · X 2 ] b) Let us define random variables X 1 and X 2 as follows: ( X 1 , X 2 ) = ( - 1 , 0) , with probability 1 4 (1 , 0) , with probability 1 4 (0 , 1) , with probability 1 2 Then E [ X 1 ] = 1 4 · ( - 1) + 1 4 · 1 + 1 2 · 0 = 0

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
E [ X 2 ] = 1 4 · 0 + 1 4 · 0 + 1 2 · 1 = 1 2 E [ X 1 · X 2 ] = 1 4 · 0 + 1 4 · 0 + 1 2 · 0 = 0 Thus E [ X 1 · X 2 ] = E [ X 1 ] · E [ X 2 ] On the other hand, Pr( X 1 = 0) = 1 / 2, but Pr( X 1 = 0 | X 2 = 1) = 1, so X 1 and X 2 are not independent. Problem 2 Suppose you write the following C code to compute the maximum number stored in an array of size n : max = a[0]; for (int i = 1; i < n; i++) { if (max < a[i]) { max = a[i]; } } Assume that the array a is a permutation of the integers { 1 , 2 , . . . , n } and each per- mutation is equally likely. What is the expected number of times the line max = a[i]; is executed?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern