# sol10 - CS 70 Fall 2010 1(50 pts Expectations Discrete...

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

CS 70 Discrete Mathematics and Probability Theory Fall 2010 Tse/Wagner Soln 10 1. (50 pts.) Expectations Solve each of the following problems using linearity of expectation. Clearly explain your methods. (Hint: for each problem, think about what the appropriate random variables should be and define them explicitly.) (a) A monkey types at a 26-letter keyboard with one key corresponding to each of the lower-case English letters. Each keystroke is chosen independently and uniformly at random from the 26 possibilities. If the monkey types 1 million letters, what is the expected number of times the sequence “bonbon" appears? Answer: Define the random variable X to be the number of times “bonbon” appears in the 1 million letters the monkey types. We express X as the sum X = 10 6 - 5 i = 1 X i where the random variable X i is X i = ( 1 if characters i ,..., i + 5 are “bonbon” 0 otherwise. Since each letter is independent, the probability that any given string of 6 letters is “bonbon” is 1 26 6 , and therefore Pr [ X i = 1 ] = 1 26 6 . Thus, E ( X i ) = 1 26 6 and so by linearity of expectation E ( X ) = E ( 10 6 - 5 i = 1 X i ) = 10 6 - 5 i = 1 E ( X i ) = 10 6 - 5 i = 1 1 26 6 = ( 10 6 - 5 ) 1 26 6 . Comment: This solution is fine, despite the fact that the X i ’s are not mutually independent. Linearity of expectation can be applied even if the underlying random variables are not independent. (b) A coin with Heads probability p is flipped n times. A “run” is a maximal sequence of consecutive flips that are all the same. (Thus, for example, the sequence HTHHHTTH with n = 8 has five runs.) Show that the expected number of runs is 1 + 2 ( n - 1 ) p ( 1 - p ) . Justify your answer carefully. Answer: Again, we use linearity of expectation. Define the random variable X to be the number of runs in a sequence, and define the indicator random variable X i as X i = ( 1 if the i th flip is the beginning of a run 0 otherwise.

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

View Full Document
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