CS02 Discrete Structures Recitation Fall 207 October 30 - November 3, 207 CS02 Week 9: Probability, Expectation, Entropy Simple Probabilities i. What is the probability that if a die is rolled five times, only two different values appear? ii. Which is more likely, rolling an when two dice are rolled, or rolling an when three dice are rolled? iii. How many ways are there for 0 people to have 5 simultaneous phone conversations?
In the Ace Discrete Math board game, moves are determined by a role of a pair of -sided dice. i. How many possible outcomes are there for a roll of this pair of dice? ii. What is the probability that the sum of the numbers rolled is 5? iii. What is the probability that the sum of the numbers rolled is 9? iv. What is the probability that both numbers rolled are odd? v. What is the probability that the numbers rolled are not equal? 2
Simple Probabilities 2 i. Yahtzee! In the dice game Yahtzee, each player has five 6-sided dice (assume dice can be differentiated). They roll them (first throw) to get five values of -6. Second throw: the player can choose to keep some of the dice values (or all, or none), and re-throw the others dice thus updating their values. Particular final dice outcomes (eg. straights, 3 of a kind, or 5 of a kind (a Yahtzee)) earn more points than others, based on how probable the outcome is. What is the probability of the following : On the first role: Getting a yahtzee with 3s Getting any yahtzee A large straight (either 2,3,,5,6 or,2,3,,5) On the first role, you have three of a kind, say three values of 2. You keep them, and re-roll the other two dice. What is the chance of A large straight A yahtzee A full house (three of a kind (value 2); and a pair same value not 2) Four of a kind (but not yahtzee) Note: For more information on Yahtzee and the actual probabilities of outcomes you can see http://mathworld.wolfram.com/yahtzee.html. 3
ii. Super Hungry Hungry Hippos The game Hungry Hungry Hippos involves players trying to catch (or eat) the most marbles using plastic hippos. Super Hungry Hungry Hippos uses kinds of marbles and the person with the most points wins. There are 0 reds ( point each), 6 greens (2 points), 3 blues (3 points), and one black super marble (6 points). Calculate the probability of the following scenarios: You catch 0 marbles (randomly) and your opponent catches 0. What is the chance you caught the black marble? What is the chance you earn exactly 0 points? What is the chance you caught exactly 2 green marbles? What is the chance you won if you only catch 6 marbles?
Expectation i. For a sequence of 3 tosses of a fair coin.. What is the size of the sample space? 2. What is the expected value for the number of heads? ii. We choose a random permutation of the numbers, 2, 3,. We get a, a 2, a 3, a. (For example we might get 2, 3,,.) What is the expected value of the number of elements such that a i = i (number of fixed points of the permutation). iii. You can play the following game 00 times: You roll a dice. If the result is x and x is even, you get x extra points to your grade in CS 02. If the result is odd you lose 3.5 points. Should you play this game? 5
iv. We roll a pair of fair dice (with 6 faces). What is the expected value for each of the following (these are random variables):. The value of the second dice. 2. The sum of the values of both dice. 3. The value of the first dice times the value of the second dice (multiplying the values). v. We toss a fair coin 2 times. We consider head as and tail as 0.. What is the expected value of the second coin toss? 2. What is the expected value of the sum of the 2 results? 3. What is the expected value of the sum of the 2 results times the result of the second toss? 6
Entropy i. You are given the following 2 codes for a, b, c, d, e, f, g, h: Letter Code Letter Code 2 a 000 a b 00 b 0 c 00 c 0 d 0 d 00 e 00 e 00 f 0 f 000 g 0 g 000 h h 0000. Encode the following strings into bits using the 2 different codes (sequences of 0 s and s). (a) abcdefgh (b) abbbadgh Which code is better? 2. Which code is better if you know that the frequency in which the letters appear is given by: Letter a b c d e f g h Frequency 6 6 6 6 7
3. Which code is better if you know that the frequency in which the letters appear is given by: Letter a b c d e f g h Frequency 6 6 6 6 7. Which code is better if you know that the frequency in which the letters appear is given by: Letter a b c d e f g h Frequency 6 6 6 6 5. Compute the entropy function H(p) for all the above distributions. If the probability is not a power of 2 you don t need to evaluate the log 2.
6. Decode the following sequence of bits into letters using code and using code 2 (It is not always the case that a sequence of bits can be decoded by 2 different codes). 000000 9
ii. You work in the cell phone company BestPhone. Your company is offering an amazing new service to its customers, the ability to send text messages with emojis. Your company allows its costumers to send 256 different emojis.. BestPhone must pay cent for each bit it sends over the network. It uses a fixed-length code to encode the different emojis. What is the minimum price that BestPhone must charge for sending an emoji in order not to lose money? 2. You did some research and you discovered that 2 of the emojis that are being sent are the smiley emoji, 256 of the emojis are the sad face, and the rest are equidistributed with probability 52. You realize that BestPhone can do better. Suggest a more efficient code. What is the minimum price that BestPhone must charge for sending an emoji in order not to lose money? Explain how can this be done. 0