Download presentation
Presentation is loading. Please wait.
Published byMercy Atkins Modified over 9 years ago
1
Expectations, Permutations & Combinations 1 Krishna.V.Palem Kenneth and Audrey Kennedy Professor of Computing Department of Computer Science, Rice University
2
Contents In-class exercise on Expectations Law of Large Numbers Fairness Permutations and Combinations In-class exercise 2
3
In-class Exercise: Application of Expectation 3 Consider the simple board without any snakes or ladders 789 654 123 Question: Calculate the expected number of rolls to reach or cross 9 from 5
4
4 Consider the following Denote expected number of rolls to reach 9 from square i as E(i) Therefore E(8) = 1 Because once you are at square 8 then independent of the outcome of the die the game is complete in one roll Consider you are at square 7 and we have to calculate E(7) 7 8 9 1/6 5/6 1 If you are in square 7, there is a 1/6 chance that you end up in square 8 (from which it will take E(8) rolls to complete the game) But there is a 5/6 chance that you complete the game in one roll from square 7 Solution
5
5 That means E(7) = probability(roll from 7 ->9) * number of rolls + [probability(roll from 7 ->8) * probability(roll from 8->9)]*number of rolls (can also be obtained from the transition diagram) Hence, E(7) = (5/6) * (1)+ [(1/6)* 1]*(2) = 7/6 7 8 9 1/6 5/6 1 Transition graph for E(6) 7 8 9 1/6 5/6 1 6 1/6 4/6 Using a similar technique, we can compute that Expected Number of Rolls E(6)49/36 E(5)343/216
6
The one with a snake 6 Question: Calculate the expected number of rolls to reach or cross 9 from 5 with a snake present
7
Transition Diagram for snake 7 7 8 9 1 6 1/6 4/6 5 1/6 3/6 1 Complete solution will be posted online
8
Calculating expected number of rolls 8 So in this case, also because square 8 will lead to the completion of game no matter what E(8) = 1 But because of the snake, when you land on square 7 you automatically move to square 5 Therefore E(7) = E(5) Let us see for square 6. Use the previous methodology From the transition diagram, E(6) = (1/6)*(E(7)+1) + [1/6*1](2) + (4/6)*(1) But we know E(7) =E(5), E(6) = (1/6)*E(5) + (7/6) Step 1 Step 2 Step 3
9
Calculating expected number of rolls 9 Let us write the equation for E(5) From the transition diagram, E(5) = (1/6)*(E(6)+1) + (1/6)*(E(7)+1) + (1/6)*(E(8)+1) + 3/6 = (1/6)*( (1/6)*E(5) + 7/6 ) + (1/6)*(E(5) + 1) + 5/6 Rearranging some terms, E(5) * [ 1 – 1/36 – 1/6 ] = 7/36 + 1 = 43/36 Therefore, E(5) = 43/29
10
Contents In-class exercise on Expectations Law of Large Numbers Fairness Permutations and Combinations In-class exercise 10
11
Law of Large Numbers The law of large numbers (LLN) describes the long-term stability of the mean of a random variable. Given a random variable with a finite expected value, if its values are repeatedly sampled, as the number of these observations increases, their mean will tend to approach and stay close to the expected value for example, consider the coin toss experiment. The frequency of heads (or tails) will approach 50% over a large number of trials. Mathematically, as an example, it can be represented as, if Mean is, then 11
12
In-Class Exercise Let us perform the virtual coin toss experiment given at http://nlvm.usu.edu/en/nav/frames_asid_305_g_3_t_5.html http://nlvm.usu.edu/en/nav/frames_asid_305_g_3_t_5.html Let ‘x’ be the random variable denoting the number of heads in a coin toss x=1 if result is head and x=0 if result is tails Observe the value of ‘x’ for n=10, 20, 50, 100, 500, 1000, using the virtual coin toss For each ‘n’, compute the difference between x that is observed and its expected value x (µ = np). 12 What do you observe as the value of ‘n’ increases?
13
13 What do you observe as the number of trials grows large ?
14
14 Can you observe that as the number of trials grows “large” the result of the experiment tends to agree with the ideal case ?
15
Contents In-class exercise on Expectations Law of Large Numbers Fairness Permutations and Combinations In-class exercise 15
16
Fairness 16 When do we say that an event is fair ? Consider the event space Event 1 Event 2 Event 3 Event 4 When all the events in the space are equally likely ? By this interpretation, are all horse races unfair in horse racing? Because usually one horse is more likely to win the race than the other. So the question is, for a game which has unequal probabilities for different Events, what has to be done to make it fair ?
17
Fairness (Contd.) 17 So to make the horse racing fair we allocate different odds for each horse. This means that the horse which is more likely to win will give you the least amount in return. This is because it was the option with the least risk Therefore the method through which a game that is biased is made fair is by using “risk”. Now no matter which horse a gambler bets, he/she will be on an equal footing with respect to others.
18
Fairness (Contd.) 18 But what did we do here ? We did not make the events equally likely We made the returns or “the expectations” of all the gamblers equal. Thus making the game fair “A experiment is fair if the expectations of all the outcomes are equal”
19
19 Consider the following game Outcome of the toss Probability of the outcome Earnings for the player who bets on it HEAD½2 chips TAIL½2 chips According to the previous definition, the above game is fair to both the players Now consider the following game Outcome of the toss Probability of the outcome Earnings for the player who bets on it HEAD2/3 TAIL1/3 Calculate the earnings for the outcomes that will make this game fair.
20
20 Essentially what we want is that, The expected earning of HEAD = The expected earning of TAIL Prob(HEAD) * Earning (HEAD) = Prob(TAIL) * Earning(TAIL) This implies, Earning(HEAD) : Earning(TAIL) = Prob(TAIL):Prob(HEAD) In this example, Earning(HEAD) : Earning(TAIL) = 1:2 Therefore to make the game fair, we have to make the earnings in the inverse ratio of the probabilities
21
Now consider the following game Outcome of the die Probability of the outcome Earnings for the player who bets on it 1p1p1 X1X1 2p2p2 X2X2 3p3p3 X3X3 4p4p4 X4X4 5p5p5 X5X5 6p6p6 X6X6 Can you state the criteria to make the above game fair to all the players ? There have been many instances when unfairness in a chance-based game was exploited to destroy kingdoms. This is the basis for the oldest epic story in the world. It is called Mahabharatha which was written in India. 21
22
The Epic of Mahabharata Kauravas challenge the honest Pandavas to a dice game with a loaded dice in their favor. In this unfair game played, the Pandavas lose their entire kingdom, were humiliated and banished into exile for 13 years. 22 It is pivoted on a gambling game between the Kaurava and Pandava clans of the royal family for the throne of Hastinapura kingdom 22 Mahabharat is an important part of Hindu mythology 22
23
The Epic of Mahabharata Kauravas challenge the honest Pandavas to a dice game with a loaded dice in their favor. 23 It is pivoted on a gambling game between the Kaurava and Pandava clans of the royal family for the throne of Hastinapura kingdom 23 Mahabharat is an important part of Hindu mythology longest epic in the world They return after the exile for revenge and win back their lost kingdom at the epic battle of Kurushetra 23
24
Contents In-class exercise on Expectations Law of Large Numbers Fairness Permutations and Combinations In-class exercise 24
25
Factorial Factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, Note that 25
26
Permutations & Combinations Permutation: An arrangement of elements from a set such that each element occurs atmost once, but not all elements of the given set need to be used order of arrangement of elements is important It is denoted by the formula where n is total number of elements in the set and r is the number of elements to be arranged Combination: An un-ordered collection of distinct elements from a given set. order of arrangements of elements is not important It is denoted by the formula where n is total number of elements in the set and k is the number of elements to be selected 26
27
Example-1 27 Question: There are 6 students to be seated on a row of 6 desks. How many ways can they be arranged if we don’t care about seating orders? Solution: Lets take one student. He/she can sit on any of the 6 desks Therefore he has 6 ways of sitting down, leaving 5 seats available for the next person. The next student has 5 places to sit down, given first student has already taken a seat. Therefore first and second student have 6x5 ways of sitting. Next we have third student. He/she has 4 ways of sitting down given first and second students have already taken 2 out of 6 desk.
28
Example-1 So the first 3 students have 6x5x4 ways of sitting down. This can be extended till we have the last student. If 5 students have taken 5 desks, the 6 th student has no choice but to take the last available desk. So he has 1 way of sitting given first 5 students have taken a desk each. Total number of arrangements = 6x5x4x3x2x1 = 6! 28
29
Example-2 Question: Using the same principle, how many different 6 letter words can you make with “potato”. Note: It does not need to make sense. For example, “otatop” is also acceptable though there is no such word Solution: Let us restate this problem Think of each letter as a student trying to sit at a desk. Let the students be called as p 1, o 2, t 3, a 4, t 5, o 6 This is like seating the 6 students on 6 desks but its not EXACTLY the same problem. Can you guess why? 29
30
30 Example-2 Let us take the following arrangement of students p 1, o 2, t 3, a 4, t 5, o 6, p 1, o 6, t 5, a 4, t 3, o 2, p 1, o 6, t 3, a 4, t 5, o 2, p 1, o 2, t 5, a 4, t 3, o 6 Here student o 2 o 6 t 3 t 5 have taken different unique positions but the word is still the same “potato”. So the number of unique words is not just 6! Do you know what the solution is? Solution: 6!/(2 x 2) Explanation: Let us assume that all letters are unique. Then, it is the same approach as finding the number of ways of seating 6 students at 6 desks Number of unique words would be 6! But we know the 2 o’s and 2 t’s are not unique.
31
31 Example-2 For every unique word, we can get 2 unique student patterns by just interchanging the the o’s. Example: p 1, o 2, t 3, a 4, t 5, o 6, p 1, o 6, t 5, a 4, t 3, o 2 So there are 2 copies of every unique word in 6! Combinations because of the o’s. Similarly for every word, we can get 2 unique student patterns by just interchanging the t’s. p 1, o 2, t 3, a 4, t 5, o 6, p 1, o 6, t 5, a 4, t 3, o 2 So there are 2 copies of every unique word in 6! Combinations because of the o’s. Therefore, the number of unique words is 6! / (No of copies due to letter o)x(No of copies due to letter t) Solution: 6! / (2x2)
32
32
33
Contents In-class exercise on Expectations Law of Large Numbers Fairness Permutations and Combinations In-class exercise 33
34
In-class Exercise Card Terminology: face value – same number cards (2-10, J, Q, K, A) has 4 cards of same face value suite – set of cards with same symbol four suites – diamond, heart, spade, clubs each suite has 13 cards Q) In a standard deck of cards, compute the number of ways you can deal each of the following five-card hands in poker. 1. Total number of different possible hands (five cards in a hand) 2. Number of distinct Flush (all 5 cards have the same suite) 3. Number of distinct Four of a kind (4 same face value cards) A) 1. C (52,5) 2. C (13,5) * C (4,1) 3. C (13,1) * C (48,1) 34
35
Use of Combinations to Calculate Probabilities Q) Now, compute the probability of getting a flush in a five- card poker game? A) Number of favorable events = C (13,5) * C (4,1) Total no. of events = C (52,5) Hence, Probability = C (13,5) * C (4, 1)/ C ( 52,5) 35 Probability of outcome No. of favorable events Total no. of events
36
END 36
37
Take Home - II 1.Let us go back to the Monty Hall Problem. Let us redefine the problem. Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say Number 3, which has a goat. He then says to you, "Do you want to pick door Number 2?" We know its advantageous to switch (based on lecture 3), so we will switch to 2 Question: Can you prove the same result i.e. “Switching in the problem of Monty hall is advantageous when compared to not switching” using Bayes Theorem?
38
Generalizing the sum of expectations result 2. Prove that the expectation of sum of n random variables is equal to the sum of expectation of the n random variables. Let x 1, x 2, x 3 …. x n be n random variables Let z = x 1 + x 2 + x 3 …. + x n To prove
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.