Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Topics • Section 6.1 – 6.6 1 Original author of the slides: Vadim Bulitko University of Alberta http://www.cs.ualberta.ca/~bulitko/W04 Modified by T. Andrew Yang ([email protected]) 2 Counting • A random process The set of outcomes is known, but the specific outcome is not predictable. – Outcomes – Sample space The set of all possible outcomes of a random process (or experiment). – Events An event is a subset of a sample space. • Examples – coins – dice 3 Counting and Probability • The chance that a given event will occur • The ratio of the number of outcomes in an exhaustive set of equally likely outcomes that produce a given event to the total number of possible outcomes • Outcomes are assumed to be equally likely. • E: an event. • S: the sample space. • N(E): the number of outcomes in E • N(S): the total number of outcomes in S. • P(E): the probability that E will occur. • Then P(E) = N (E) N (S ) • Examples: – Coins – Dice – Tournament 4 Permutations, combinations, etc. Attributes Ordered Unordered Reps No Reps 5 Multiplication Rule • p.208: Theorem 6.2.1 k steps (s1, s2, …, sk) of an operation n1 ways in s1 n2 ways in s2 … Then, the entire operation can be performed in n1n2…nk ways. 6 Multiplication Rule (cont.) • Example: – How many different PINs are possible? p.308 (repetition is allowed) – How if repetition is not allowed? p.309 permutations (p.313) – Password-based authentication 7 Passwords-based Authentication • A dictionary attack is the guessing of a password by repeated trial and error. • The dictionary may be a set of strings in random order, or a set of strings in decreasing order of probability of selection. 8 Passwords-based Authentication • Countering dictionary attack – – The goal: To maximize the time needed to guess the password TG Anderson’s Formula: P N P: The probability that an attacker guesses a password in a specified period of time G: The number of guesses that can be tested in one time unit T: The number of time units during which guessing occurs N: The number of possible passwords 9 Passwords-based Authentication • An example: – Let S be the length of the password. – Let A be the number of characters in the alphabet from which the characters of the password are drawn. Then N = AS. – Let E be the number of characters exchanged when logging in. – Let R be the number of bytes per minute that can be sent over a communication link. – Let G be the number of guesses per minute. Then G = R / E. – If the attack extends over M months, T = 30 x 24 x 60 x M. – Let P be the probability that the attack would succeed. Then TG P N 10 Passwords-based Authentication • Analysis of the Anderson Formula: TG P N – The goal is to maximize the time (T) needed for the attacker to guess the password. – That is, to decrease the chance that the attack may succeed (P). • Approaches: – To increase N, the set of possible passwords – To decrease the time allowed to guess the passwords, that is, to reduce T – To decrease G 11 Possibility Trees • Used to count the number of outcomes • Can be used to illustrate the multiplication rule (e.g., toss a coin for three times) • Useful when the multiplication rule is difficult or impossible to apply • Examples – Possibilities for tournament play: p.306 – Election of officers: p.311 12 Permutations • A permutation of a set of objects is an ordering of the objects in a row. • Example: S = {a, b} Permutations: ab, ba Order matters! Distinct objects! • Formula Given n objects (n >= 1), the number of permutations is n! 13 r-permutations • An ordered selection of r elements out of n elements • Still, order matters and no repetition P(n,r) = n(n-1)(n-2)…(n-r+1) n! = ( n r )! • Exercises: P(5,3), P(7,3), P(3,3) • Example 6.2.11 (p.317) • Q16 on p.319 14 Set Operations & Counting • The addition rule (p.321) Example 6.3.1: number of passwords Note: distinct, mutually disjoint sets • To make sets disjoint: intersection, symmetric difference • Inclusion/exclusion, difference rules – Example 6.3.6 15 Combinations • Order is not important (i.e., sets) • c.f., Order is important in permutations • So, the different combinations can be considered as subsets of a given set • Example 6.4.2 (p.335) S = {0,1,2,3} Q: How many unordered selections of two elements can be made from S? 16 r-combinations • An r-combination of a set of n elements is a subset of r of the n elements • n choose r: the number of r-combinations that can be chosen from a set of n elements Note: Order is not important, No repetition of elements • p.364: computing binomial coefficients • Formula n n! r r!( n r )! • Example 6.4.10: p.344 17 r-permutations vs r-combinations • Share: no repetitions, distinct elements • Difference: – Permutations: unordered – Combinations: ordered • Figure 6.4.1: p.336 • n P( n, r ) * r! r 18 Be aware of double-counting! • A false solution: p.346 • Another example: M={a,b}, F={c,d,e}. Form 2-person teams, but one of them must be a woman. • Questions to ask: – Am I counting everything? – Am I counting anything twice? • Multiplication rule – Am I looking at everything at the possibility tree? – Does every outcome appear on a branch of tree? • Addition rule: – Does every outcome appear in some subset of the diagram? – Are the subsets disjoint? 19 r-permutations with repetition • r-permutations without repetitions: order matters P(n,r)=n(n-1)(n-2)…(n-r+1) • What if we allow to put elements back? • How many ways can we choose r elements from n types of elements? – Order matters – Repetitions are allowed • Formula? 20 Permutations of a set with repeated elements • Theorem 6.4.2: p.345 • Example 6.4.11 n n n1 n n1 n2 n n1 n2 ... nk 1 ... n1 n2 n3 nk n! n1! n2 ! n3 !...nk ! • Which to use? c.f.: nk • Q1: How many different bit strings can 4 bits hold? • Q2: What are the total number of transpositions for the 4-bit bit string 0110b? That is, how many 4-bit bit strings contain exactly 2 1’s? 0110, 0101, 1010, 1001 See example 6.4.10 (p.344) • Exercise: Try the same with 5 bits 21 Special case n n n1 n n1 n2 n n1 n2 ... nk 1 ... n1 n2 n3 nk n! n1! n2 ! n3 !...nk ! •When k = 2, permutations with repeated elements is reduced to r-combinations. True? False? 22 r-combinations with repetition • What if we allow repetitions? • Choose r elements out of n but allow repetitions (e.g., put the elements back after drawing them) • Order is not important • The underlying construct is multiset • Theorem 6.5.1: p.351 • Examples 23 Summary Attributes Ordered Unordered Reps r-permutations r-combinations No Reps • Question: How about n n n1 n n1 n2 n n1 n2 ... nk 1 ... n n n n 1 2 3 k n! n1! n2 ! n3 !...nk ! 24 Questions? 25