Probability and Statistics with Integrated Software Routines Chapter
Probability and Statistics with Integrated Software Routines Chapter 1 Introduction to Probability 12/7/2020 rd 1
Probability Quotes How dare we speak of the laws of chance? Is not chance the antithesis of all law? ~ Bertrand, Joseph I will never believe that god plays dice with the universe. ~ Albert Einstein Information: the negative reciprocal value of probability. ~ Claude Shannon IA = Log 2 1/P(A) = -Log 2 P(A) What the use of P implies, therefore, is that a hypothesis that may be true may be rejected because it has not predicted observable results that have not occurred. ~ Jeffreys 12/7/2020 rd 2
Taking Chances If You Bet on a Horse, That’s Gambling. If You Bet You Can Make 3 Spades, That’s Entertainment. If You Bet the Structure Will Last 100 Years, That’s Engineering. You see the Difference? 12/7/2020 rd 3
Random What does random mean? What is the probability that a randomly drawn chord is shorter than the leg of the equilateral triangle in the circle? 2/3 Repeat for the perpendicular at the midpoint of the radius through arbitrary point c. inside the circle ¼ = r 2/4 / r 2 2/3 ½ ¼ A c x B C Which answer is correct? Both are, mathematically. So what does "at random" mean? 12/7/2020 rd 4
Sample Space A well defined experiment produces one of a given set of outcomes. The outcomes (subsets) are called events. The set of all elementary (finest granularity) events is called the sample space. Subsets of elementary events are called compound events. A trial is a single performance of an experiment. Also a set of trials as in rolling a die 5 times may be designated as a trial. Repeat this experiment for 3 trials. Example: Experiment is the rolling of a fair die. The 6 elementary events are the 6 faces 1 to 6. The event even is a compound event consisting of the 3 elementary events 2, 4, 6. Each roll of the die is a trial. The event prime and odd {3 5}is a compound event. 12/7/2020 rd 5
Experiment: Rolling a Die Sample Space {1 2 3 4 5 6} Events: Subsets of sample space Occurrence of an event: Element is in the event. Default symbol for a RV is X and its value is x. P(X = 3) = 1/6, the probability of rolling a 3 with a die. P(X < 3) = 2/6; Trial is the conducting of an experiment. Statistician's definition of probability #Favorable / #Total X 1 2 3 4 5 6 P(X) 1/6 1/6 1/6 E(X) = 1*1/6 + 2*1/6 + 3*1/6 + 4*1/6 + 5*1/6 + 6*1/6 = 3. 5 = . E(X 2) = 1*1/6 + 4*1/6 + 9*1/6 + 16*1/6 + 25*1/6 + 36*1/6 = 91/6 V(X) = E(X 2) – [E(X)]2 = 91/6 – 12. 25 = 35/12 = 2. 12/7/2020 rd 6
Probability Theorems A is an event set in the sample space S. 1. 0 P(A) 1; Probability is never negative. 2. P(S) = 1; Probability of the certain event is 1. 3. For mutually exclusive (disjoint) events (sets) Ai P( Ai) = P(Ai) The probability of disjoint subsets is the sum of the individual probabilities of the subsets. If A and B are mutually exclusive, P(A + B) = P(A) + P(B) If A and B are independent, P(AB) = P(A) * P(B) and also P(A|B) = P(A) = 1 – P(Ac) For events A and B, P(A + B) = P(A) + P(B) – P(AB) Inclusive/Exclusive Principle 12/7/2020 rd 7
Granularity Find the probability a that A randomly drawn card from a deck of 52 cards is an ace. Considering suits: P(AC + AD + AH + AS) = 1/52 + 1/52 = 4/52 The intersections of the aces (suits) are all empty. Considering cards, P(ace) = 4/52 Considering rank, P(ace) = 1/13 A S Find the probability the card is not an ace nor a spade. P(~A, ~S) = 1 – P(A + S) = 1 – P(A) – P(S) + P(AS) (52 -16)/52 = 1 – 4/52 – 13/52 + 1/52 = 36/52 = 9/13. 12/7/2020 rd 8
Conditional Probability Urn X has 3 Red and 2 blue marbles; Urn Y has 5 red and 10 blue marbles. The symbol | means given that. X Y 3 R 5 R (X, B) means Urn X and Blue 2 B 10 B P(X, B) = (1/2)(2/5) = 1/5; P(X, R) = 3/10 P(X) = P(Y) = ½ P(Y, B) = (1/2)(2/3) = 1/3, P(Y, R) = 1/6 P(Blue|X) = 2/5; P(Red|X) = 3/5; P(Blue|Y) = 10/15; P(Red|Y) = 5/15 P(Blue) = (1/2) * (2/5) + (1/2) * 10/15) = 8/15 (2+10)/20 P(Red) = (1/2) * (3/5) + (1/2) * 5/15) = 7/15 (3 + 5)/20 12/7/2020 rd 9
Bayes's Theorem Urn X has 3 Red and 2 blue marbles; Urn Y has 5 red and 10 blue marbles. X Y Urn X Urn Y Total 3 R 5 R R 3/10 1/6 14/30 2 B 10 B B 1/5 1/3 16/30 Total ½ 1 P(X) = P(Y) = ½ P(X|R) = (3/10)/(14/30) = 9/14 P(X|R) = P(R|X)*P(X) / [P(R|X)*P(X) + P(R|Y)*P(Y)] = (3/5) * (1/2) 3/10 (3/5)*(1/2) + (5/15)*(1/2) 7/15 = 9/14 12/7/2020 rd 10
Bayes's Theorem Revisited Suppose that 5% of a population have a disease and that a test to detect or not-detect is 95% accurate. Suppose a person is tested for the disease with positive result. Find the probability that the person actually has the disease. Disease, Tested Positive, No Disease P(D|TP) = P(TP|D) * P(D) + P(TP|ND) * P(ND) = 0. 95 * 0. 05 + 0. 05 * 0. 95 = ½ 12/7/2020 rd 11
Bayes's Theorem ¾% of a population have a disease. The test is 99% accurate in identifying those with the disease and 95% accurate in identifying those who do not have the disease. D = disease; ND = no disease, TP = tested positive; TN = tested negative TPC = Tested positive correctly Sensitivity = TPC/(TPC + TNI) TPC/have D Type I Specificity = TNC/(TPI + TNC) TNC/have ND Type II Positive predictive value = TPC/(TPC + TPI) Negative predictive value = TNC/(TNC + TNI) Prevailing rate = (TPC + TNI)/(TPC + TNI + TPI + TNC) 12/7/2020 rd 12
Simulation of Coin Flips Law of Large Numbers (sim-coins-1 -1 100 1/2 10) (sim-coins 100 1/2 10) 1 2 3 4 5 6 7 8 9 10 #Heads #Flips P(H) 50 49 44 55 64 45 56 45 58 50 516 1000 0. 516 110 105 89 104 106 85 94 92 103 991 2000 0. 4955 146 136 149 162 145 159 157 144 1507 3000 0. 502333 207 197 215 195 204 194 207 197 202 205 2023 4000 0. 50575 245 272 248 227 223 226 280 271 239 254 2485 5000 0. 497 298 312 326 319 298 311 313 290 278 3053 6000 0. 508833 335 337 368 340 356 323 334 358 352 383 3486 7000 0. 498 409 417 415 419 372 391 374 397 408 401 4003 8000 0. 500375 441 432 463 448 457 434 458 460 437 473 4503 9000 0. 500333 480 504 481 503 504 478 509 481 486 511 4937 10000 0. 4937 12/7/2020 rd 13
Two Fundamental Principles of Counting (FPC) and the Pigeonhole Principle Addition Principle: If there are n 1 different items in set 1, n 2 different items in set 2, etc. for r disjoint sets, then the number of ways to select an item from one of the r sets is n 1 + n 2 + … + nr. Multiplication Principle: If there are n 1 outcomes for the first decision in stage 1 followed by n 2 outcomes for the second decision in stage 2 followed by n 3 for the 3 rd decision in stage 3, etc. for r stages, where each decision is independent of all prior decisions, then all togethere are n 1 * n 2 *. . . * nr. This Cartesian product is the total number of ways that the r sequence of decisions can be made. Pigeonhole Principle: If the number of pigeons exceeds the number of pigeonholes, then at least one pigeonhole has at least 2 pigeons. 0 1 2 3 4 5 6 7 8 9 ? Can 54 marbles be put into 11 bins with a different number in each? (sum (upt 0 9)) 45 12/7/2020 rd 14
How many ways are there to. . . (a) distribute 12 identical pieces of candy to 6 children if some children may receive none? (6188) (comb 17 5) (coef (poly^n #(x 1 1 1 1) 6) 12) 6188 (b) distribute 12 identical pieces of candy to 6 children if each child receives at least one? (462) (comb 11 5) (coef (poly^n #(x 0 1 1 1) 6) 12) 462 (c) assign 5 people to 3 tasks if each task may have zero or more people assigned to it? (243) 35 (d) assign 5 people to 3 tasks if each task must have at least one person assigned to it? (150) 35 - 3 * 25 + 3 * 15 - 1 * 05 (e) walk an increasing grid path from 4 th Ave. & 3 rd St. to 9 th Ave. & 12 th St. ? (2002) (Comb (+ (- 9 4) (- 12 8)) 5) 126 (f) walk an increasing grid path if one takes 10 steps? (1024) 210 (g) walk an increasing grid path from (0, 0) to the line x + y = 10? (1024) 210 12/7/2020 rd 15
Fundamental Principles of Counting & Pigeon Hole a) At a picnic of 50 people, 30 had ham. Burgers, 25 had hot. Dogs, and 15 had both. How many had neither? N(~B, ~D) = N – N(burger + dog) = 50 – 30 – 25 + 15 = 10 b) How many ways can a 20 -question true/false test be answered? 220 = 1, 048, 576 N c) In a drawer are 12 black socks and 12 white socks. What is the minimum number of socks one can randomly pull from the drawer to ensure getting a matching pair? d) In an urn are 3 red, 4 white and 5 blue marbles. How many ways can a sample of 4 marbles be drawn with at least one of each color? 12/7/2020 rd 16
Pigeon-Hole Principle Ten couples (M&F) meet for lunch. After a cocktail they go into the dining room in a random order, one by one. How many people must enter the dining room to assure that: 1. There is at least one married couple in the group? 2. There at least two diners of the same sex? 3. Show that at least two people in Dayton, Ohio have the same initials. 12/7/2020 rd 17
Independent Events A and B are independent if P(AB) = P(A)*P(B). Let A be ace and C club in card selection. Are A and C independent? Yes; P(AC) =1/52 =P(A)*P(C) = 4/52 * 13/52 If A is independent of B, is A also independent of Bc? YES P(A) = P(AB) + P(ABc) = P(A)*P(B) + P(ABc) P(A)[1 – P(B)] = P(ABc) P(A)*P(Bc) = P(ABc) If A is independent of B, and B of C, is A also independent of BC? Not necessarily. In throwing a pair of fair dice; Counterexample: A: sum of dice is 7, B: first die = 4 and C: second die = 3. 12/7/2020 rd 18
Factorial n! is s the product of all positive integers less than or equal to n. n! = n(n – 1)! = 0! = 1 5! = 5 * 4 * 3 * 2 * 1 = 120 10! = 3628800 100! = 93326215443944152681699238856266700490715968264 38162146859296389521759999322991560894146397615 6518286253697920827223758251185210916864000000000 (f 5) 120 12/7/2020 rd 19
Combinations 8 C 3 = C(8, 3) = (comb 8 3) 56 (comb 52 5) 2598960; (comb 20 18) 12/7/2020 rd 20
Selected Not Selected (comb-list '(A B C D E) 3) Selected: ((A B C) (A B D) (A C D) (B C D) (A B E) (A C E) (B C E) (A D E) (B D E) (C D E)) Not-Selected: ((D E) (C E) (B E) (A E) (C D) (B D) (A D) (B C) (A B)) OUT IN Pick x, not in selection 12/7/2020 rd 21
Pascal's Triangle (1) (1 2 1) (1 3 3 1) (1 4 6 4 1) (1 5 10 10 5 1) (1 6 15 20 15 6 1) (1 7 21 35 35 21 7 1) (1 8 28 56 70 56 28 8 1) (1 9 36 84 126 84 36 9 1) 12/7/2020 rd 22
Permutations Example: For selection {8 5 1} => 3*2*1 permutations 8 P 3 = P(8, 3) = (perm 8 3) 336 (perm 52 5) 311, 875, 200 = 5! * (comb 52 5) 2598960 12/7/2020 rd 23
Print-Permutations (print-permutations (upto 5)) (1 2 3 4 5)(1 2 3 5 4)(1 2 4 3 5)(1 2 4 5 3)(1 2 5 3 4)(1 2 5 4 3)(1 3 2 4 5)(1 3 2 5 4)(1 3 4 2 5)(1 3 4 5 2)(1 3 5 2 4)(1 3 5 4 2)(1 4 2 3 5)(1 4 2 5 3)(1 4 3 2 5)(1 4 3 5 2)(1 4 5 2 3)(1 4 5 3 2)(1 5 2 3 4)(1 5 2 4 3)(1 5 3 2 4)(1 5 3 4 2)(1 5 4 2 3)(1 5 4 3 2)(2 1 3 4 5)(2 1 3 5 4)(2 1 4 3 5)(2 1 4 5 3)(2 1 5 3 4)(2 1 5 4 3)(2 3 1 4 5)(2 3 1 5 4)(2 3 4 1 5)(2 3 4 5 1)(2 3 5 1 4)(2 3 5 4 1)(2 4 1 3 5)(2 4 1 5 3)(2 4 3 1 5)(2 4 3 5 1)(2 4 5 1 3)(2 4 5 3 1)(2 5 1 3 4)(2 5 1 4 3)(2 5 3 1 4)(2 5 3 4 1)(2 5 4 1 3)(2 5 4 3 1)(3 1 2 4 5)(3 1 2 5 4)(3 1 4 2 5)(3 1 4 5 2)(3 1 5 2 4)(3 1 5 4 2)(3 2 1 4 5)(3 2 1 5 4)(3 2 4 1 5)(3 2 4 5 1)(3 2 5 1 4)(3 2 5 4 1)(3 4 1 2 5)(3 4 1 5 2)(3 4 2 1 5)(3 4 2 5 1)(3 4 5 1 2)(3 4 5 2 1)(3 5 1 2 4)(3 5 1 4 2)(3 5 2 1 4)(3 5 2 4 1)(3 5 4 1 2)(3 5 4 2 1)(4 1 2 3 5)(4 1 2 5 3)(4 1 3 2 5)(4 1 3 5 2)(4 1 5 2 3)(4 1 5 3 2)(4 2 1 3 5)(4 2 1 5 3)(4 2 3 1 5)(4 2 3 5 1)(4 2 5 1 3)(4 2 5 3 1)(4 3 1 2 5)(4 3 1 5 2)(4 3 2 1 5)(4 3 2 5 1)(4 3 5 1 2)(4 3 5 2 1)(4 5 1 2 3)(4 5 1 3 2)(4 5 2 1 3)(4 5 2 3 1)(4 5 3 1 2)(4 5 3 2 1)(5 1 2 3 4)(5 1 2 4 3)(5 1 3 2 4)(5 1 3 4 2)(5 1 4 2 3)(5 1 4 3 2)(5 2 1 3 4)(5 2 1 4 3)(5 2 3 1 4)(5 2 3 4 1)(5 2 4 1 3)(5 2 4 3 1)(5 3 1 2 4)(5 3 1 4 2)(5 3 2 1 4)(5 3 2 4 1)(5 3 4 1 2)(5 3 4 2 1)(5 4 1 2 3)(5 4 1 3 2)(5 4 2 1 3)(5 4 2 3 1)(5 4 3 1 2)(5 4 3 2 1) 12/7/2020 rd 24
Binomial Identities a. Express the sum of consecutive integers from 1 to n using combinations. 0 1 2 3 (comb (+ n 1) 2) 3 2 1 0 Sum of first 100 integers is (comb 101 2) 5050 1 2 3 4 5 6 6*7/2 n(n + 1)/2 6 5 4 3 2 1 b. Express the sum of consecutive integers squared from 1 to n using combinations. (+ (* 2 (comb (+ n 1) 3)) (comb (+ n 1) 2)) Sum of first 100 squared integers (+ (* 2 (comb 101 3)) (comb 101 2)) 338350 12/7/2020 rd 25
Permutations vs. Combinations Both are ways to count the possibilities The difference between them is whether order matters. Consider poker hand: Is this the same hand: A♠, 6♥, 2♣, 10♠, K♠. K♠, 2♣, 10♠, A♠, 6♥? Does the order of the cards dealt matter? If yes, then we are dealing with permutations. If no, then we are dealing with combinations.
Selection with Repetition How many ways can you distribute (select) 3 items from 2 different types (2 bins)? Ans. (comb 4 1) = (comb 4 3) = 4 See below the 3 X-items and the one divider modeling the two different types. a. 0, 3 b. 1, 2 c. 2, 1, d. 3, 0. X X X a. X X X b. c. X X X d. Notice you are manipulating the 3 + 2 -1 objects taken 1 at a time (the divider) or 3 at a time (the x-items) Canonical patterns: 03 12 (poly^n #(X 1 1) 2) e 1 + e 2 = 3 2 + 2 = 4 12/7/2020 rd 27
Quick Probability Problems 1. If repetitions are not permitted, (permutations) a) How many 3 digit numbers can be formed from the 6 digits in {2, 3, 5, 6, 7, 9}? 6 * 5 * 4 = 120 b) How many are less than 400? 2 * 5 * 4 = 40 c) How many are even? 5 * 4 * 2 = 40 d) How many are odd? 5 * 4 = 80 e) How many are multiples of 5? 5 * 4 * 1 = 20 12/7/2020 rd 28
2. Repeat #1 if repetitions are permitted in {2, 3, 5, 6, 7, 9}. a. 6 * 6 = 216 b. 2 * 6 = 72 < 400 c. 6 * 2 = 72 d. 6 * 4 = 144 e. 6 * 1 = 36 3. Consider the 3 letters in the set {a, b, c}. a) List the combinations for the 3 letters taken 3, 2, 1 and 0 at a time and the corresponding permutations. Combinations Permutations 3 C 3 = {abc} abc, bca, cab, acb, bac, cba 3 C 2= {ab, ac, bc} ab, ba ac, ca, bc, cb 3 C 1 = {a, b, c} a, b, c 3 C 0 = 1 don’t play P(3, 0) = 1 don't take any 12/7/2020 rd 29
4. a) An octagon has how many diagonals? 8 C 2 - 8 = 28 - 8 = 20; lines – sides = diagonals b) An n-gon has how many diagonals? n. C 2 - n = n(n-1)/2 - n = n(n - 3)/2 . c) What regular polygon (n-gon) has the same number of diagonals as sides? n. C 2 - n => n(n - 1) = 4 n => n = 0 or 5 => Pentagon d) What n-gon has 3 less diagonals than sides? n. C 2 - n = n – 3 n(n - 1) = 4 n – 6 => n 2 -5 n + 6 = 0 = (n - 2)(n - 3); n = 3 12/7/2020 rd 30
5. Determine the probability p for each of the following. a) an even number appears in the toss of a die; 3/6 b) a jack appears in drawing a card from a deck; 4/52 c) at least one head appears in tossing 3 coins; 7/8 = 1 – P(0 head) = 1 – ½ * ½ d) a red marble is drawn from an urn containing 4 white, 5 red, and 6 blue marbles. 5/15; sampling without replacement e) both cards are hearts drawn from a deck. (13/52)(12/51); sampling without replacement 12/7/2020 rd 31
6. Of all couples who have exactly two children, what is the probability that both are a) Boys? 1/4 BB, BG, GB b) Boys given that at least one is a boy? 1/3 BB, BG, GB c) Boys given that the older child is a boy? 1/2 BB, BG, GB 7. Three fair coins are tossed. Find the probability of exactly 2 heads. A canonical pattern is HHT => 3!/2!1! = 3 ways Space: {HHH HHT HTH HTT THH THT TTH TTT} 3/8 12/7/2020 rd 32
Two Boys One of all parents who have two children is selected and states that he has a boy born on a Monday. What is the probability that the other child is also a boy? B-Mo, B-Tu, B-We, B-th, B-Fr, B-Sa, B-su G-Mo, G-Tu, G-We, G-th, G-Fr, G-Sa, G-su Sample Space: BMBM BMBT BMBW BMBt BMBF BMBS BMBs BMGM BMGT BMGW BMGt BMGF BMGS BMGs BTBT BWBW Bt. Bt BFBF BSBS Bs. Bs BMGM BMGT BMGW BMGt BMGF BMGS BMGs 13/27 12/7/2020 rd 33
8. A coin with P(H) = 2/3 is tossed. If head appears, a number is selected at random from the set 1 to 9. If tail appears, a number is selected at random from the set 1 to 5. Find the probability that an even number is selected. {1 2 3 4 5 6 7 8 9}; {1 2 3 4 5} Seeking the total probability of the event even: P(even) = P(even|H)P(H) + P(even|T)P(|T) = (4/9)*(2/3) + (2/5)*(1/3) = 58/135 = 0. 429629 Heads Tails Even (2/3)*(4/9) (1/3)(2/5) 58/135 12/7/2020 rd 34
9. Box A contains 9 cards numbered 1 through 9; Box B contains 5 cards numbered 1 through 5. A box is chosen at random and a card is drawn. If the number is even, find the probability that the card came from Box A? Assume P(Box A) = P(Box B) implicitly. P(A) = P(B) = 1/2 P(Even) = P(Even|A)P(A) + P(Even|B)P(B) = (4/9) * (1/2) + (2/5) * (1/2) = (1/2) * 38/45 = 19/45 = 0. 42222. P(A|Even) = P(A, Even)/P(Even) = [(1/2)*(4/9)] / (19/45) = 10/19. 12/7/2020 rd 35
10. Consider a card drawn from a deck of 52 playing cards. a) What is the prior probability that the card is a queen? b) If you see that it is a face card, (JQK) what is the posterior probability that the card is a queen? a. 4/52 b. P(Q|FC) = P(Q, FC)/P(FC) = (4/52)/(12/52 ) = 4/12 10 b. If you roll two dice, what is the probability that the sum is odd? Look at one die. The probability lies on the second die; hence ½. 12/7/2020 rd 36
11. The probability of 4 aces in 5 -card poker is 48/52 C 5. Odds are 54, 144 : 1 against [ACADAH AS x] 12. The probability that the 4 aces occur consecutively in a deck of 52 cards is 49/52 C 4 = 0. 0001809 or 5524 : 1 Favorable: 1 -4, 2 -5, … 49 -52 (C or P? ) 13. The probability of 4 aces in a bridge hand (13 cards) is [4 C 4 *48 C 9] / 52 C 13 = 0. 002641, or 378 : 1 AGAINST 14. The probability of 4 aces and 4 kings in a bridge hand is [4 C 4 * 44 C 5 ] / 52 C 13 = 11/6431950 = 1. 7102 E-6 odds = 584, 722 : 1 AGAINST. 12/7/2020 rd 37
15. The probability of 4 aces or 4 kings in a bridge hand is P(4 A + 4 K) = P(4 A) + P(4 K) – P(4 A, 4 K) [48 C 9 /52 C 13 + 48 C 9 /52 C 13] - 44 C 5 / 52 C 13. = 0. 0052804 or the odds are 188 : 1 16. The probability of a full house in a toss of 5 fair dice is 0. 03858. [xxx yy] [6 C 2 * 2 C 1 *5 C 3 * 2 C 2] / 65 = 300/7776 = 0. 03858 or Odds = 25 : 1 12/7/2020 rd 38
P(13 clubs in Bridge) = 1/52!/(13!)4 39!/(13!)3 / 52!/(13!)4 north west east 12/7/2020 south rd 39
Poker probability: royal flush What is the chance of getting a royal flush? The cards are 10, J, Q, K, and A of the same suit Four Suits; hence 4 possible royal flushes Possibilities for 5 cards: C(52, 5) = 2, 598, 960 Probability = 4/2, 598, 960 = 0. 000001539077 Or about 1 in 650, 000 (/ (- 1 1. 539077 e-6) 649739. 042816 12/7/2020 rd 40
Poker hand odds The possible poker hands are (in increasing order): Nothing One pair Two pair Three of a kind Straight Flush Full house Four of a kind Straight flush Royal flush 12/7/2020 1, 302, 540 1, 098, 240 123, 552 54, 912 10, 200 5, 140 3, 744 624 36 4 rd 0. 5012 0. 4226 0. 0475 0. 0211 0. 00392 0. 00197 0. 00144 0. 000240 0. 0000139 0. 00000154 41
17. Statistics: Most car accidents occur at moderate speeds. Very few accidents occur at speeds above 80 miles per hour. Is it safer to drive at higher speeds? If more people die from tuberculosis in Arizona than any other state, does that mean that Arizona's climate is bad for tuberculosis? Children with big feet could spell better than children with little feet. Is there a casual correlation? Most car accidents occur within 25 miles of your home. Should you move? 12/7/2020 rd 42
18. Compute the probability of winning at the game of craps, where a sum of 7 or 11 on the first roll of a pair of fair dice wins and a sum of 2, 3 or 12 loses; any other sum becomes your point, and you must make your point before a sum of 7 is thrown. P(win)= P(7)+P(11)+2[P(4), P(4|4+7)+P(5), P(5|5+7)+P(6), P(6|6+7)] = 1/6 + 1/18 + 2[(3/36) (3/9) + (4/36)(4/10) + (5/36)(5/11)] = 0. 4929292. P(S 4|S 4 OR S 7) means game point is 4 and that a sum of 4 occurs before a sum of 7. X 2 3 4 5 6 7 8 9 10 11 12 P(X) 1 2 3 4 5 6 5 4 3 2 1 / 36 12/7/2020 rd 43
19. What is the probability of at least 2 people sharing a birthday (day and month) in a group of n people? P(n people not sharing) = P(sharing) = 1 – P(sharing with n = 23) is (- 1 (/ (permutation 365 23) (expt 365 23))) 0. 507297 12/7/2020 rd 44
20. A fair pair of dice are rolled 7 times. Compute the probability of 3 S 7, 3 S 6, and S 5 (multinomial distribution). P(S 7) = 1/6; P(S 6) = 5/36; P(S 5) = 4/36 P(3 S 7, 3 S 6, 1 S 5) = = 0. 0005788 or 1728 : 1 21. In the expansion of (x + y + z + w)10, what is the coefficient of the x 2 y 2 z 3 w 3 term? (poly^n #(W #(X #(Y #(Z 0 1) 1 ) 1) 1) 10) 10! /(2! 2! 3! 3!) = 25200. 12/7/2020 rd 45
Probability Thoughts 1. How many ways to pick 2 cards from a deck of 52 so that the first card is an ace and the second card is not a queen? 4 * (51 – 4) or 4 * 47 = 188 … First card is a spade and second card is not a queen? 1 * 48 + 12 * 47 = 612. (QS * ~Q) + (S but ~QS) * ~Q 12/7/2020 rd 46
Smallest Integer 2. Compute the probability that k is the smallest integer in a subset of 4 different numbers chosen from 1 through 20 (1 k � 17). Second smallest? __ __ Assume k = 8. Focus on number remaining to be chosen. The other 3 numbers can be chosen from (/ (comb (- 20 8) 3) ; (/ (comb (- n k) 3) (comb 20 4)) 44/969 (comb 20 4) Second smallest probability for k = 8 7 C 1 1 12 C 2 (/ (* (comb (- k 1) 1) 1 (comb (- 20 k) 2)) (comb 20 4)) 12/7/2020 rd 47
Number of 5's 3. Count the number of 5's when listing the integers from 1 to 100, 000. How many 5's from 0 to 99? 5 x 104 with one 5 in each position and 10 in the other 4 positions * 10 10 10 10 10 * 10 10 * 12/7/2020 rd 48
Letter Sequence 4. How many ways can one select a 3 -letter sequence using letters a b c d e f with a) repetition; b) without repetition, c) without repetition and containing e, d) with repetition and containing e. Solution a) 6 * 6 = 216 b) 6 * 5 * 4 = 120 c) (1 * 5 * 4) + (5 * 1 * 4) + (5 * 4 * 1) = 60 d) e _ _ + _ e _ + _ _ e => 1*6*6 + 5*1*6 + 5*5*1 = 91. 12/7/2020 rd 49
Inclusion/Exclusion Principle P(A + B) = P(A) + P(B) – P(AB) A B A AB B ABC C P(A + B + C) = P(A) + P(B) + P(C) - P(AB) - P(BC) + P(ABC) P(A|B) = P(AB)/P(B) => P(AB) = P(A|B)P(B); Consider fair die roll. P(2|even) = P(2, even)/ P(even) = (1/6)/(3/6) = 1/3. 12/7/2020 rd 50
Problem 1 -1 5. In tossing a fair die, compute the probability of a face showing a) an even numeral. P(even) = 3/6 = 1/2. b) a 2 or 4 or not 6 by using the inclusion/exclusion template P(A + B + C) = P(A) + P(B) + P(C) - P(AB) - P(AC) - P(BC) + P(ABC)) P(2 or 4 or ~6) = P(2) + P(4) + P(~6) - P(2, 4) - P(2, ~6) - P(4, ~6) + P(2, 4, ~6) = 1/6 + 5/6 - 0 - 1/6 + 0 = 5/6. c) P(3 before a 4) = 1/(1 + 1) = ½ as there is 1 way for a 3 to occur and 1 way for a 4. d) P(3 before a 5 or 6) = 1/(1 + 1) = 1/3. e) less than 4; P(D < 4) = P(D 1 + D 2 + D 3) = 1/6 + 1/6 = 1/2. 12/7/2020 rd 51
Polynomial Expansions 6. Write out the coefficient of the x 2 y term in the expansion of (x + y + z)3. (x + y + z)2 = x 2 + xy + xz + yx + y 2 + yz + zx + zy + z 2 = x 2 + 2 xy + 2 xz + 2 yz + y 2 + z 2 (x + y + z)3 = x 3 + 2 x 2 y + 2 x 2 z + 2 xyz + 1 xy 2 + xz 2 + x 2 y + 2 xy 2 + 2 xyz + 2 y 2 z + y 3 + yz 2 + 1 x 2 z + 2 xyz + 2 xz 2 + 2 yz 2 + y 2 z + z 3 = x 3 + y 3 + z 3 + 3 x 2 y + 3 x 2 z + 3 y 2 z + 3 xy 2 + 3 xz 2 + 3 xy 2 + 3 yz 2 + 6 xyz or 3!/(2!1!0!) = 3 7. Write out the coefficient of the x 3 y 4 z 6 in the expansion of (x + y + z)13. (poly^n #(X #(Y #(Z 0 1) 1) 1) 13! /(3! 4! 6!) = 60060 3!4!6! xxxyyyyzzzzzz permutations 12/7/2020 rd 52
Polynomial Expansions a b c 8. Write out the coefficient of the x 3 y 4 z 6 in the expansion of (ax + by + cz)13. (u + v + w)13 a 3 b 4 z 6 * 13!/(3!)(4!)(6!) 12/7/2020 rd 53
Conditional Probability In an urn are r red balls and g green balls. You randomly select a ball and toss it aside unseen. You then randomly select another ball. What is the probability that the ball is red? r * r – 1 + g * r = r r + g – 1 r + g r(r – 1) + rg = r(r + g – 1) = r (r + g)(r + g – 1) r + g 12/7/2020 rd 54
Generating Function The generating function for the binomial coefficients is 12/7/2020 rd 55
Generating Function Models for distributing 2 items into 4 bins x 0 Combination I/E x 1 * x 1 x 2 e 1 + e 2 + e 3 + e 4 = 2; 0 ei 2; canonical patterns: 0002; 0011 4 integers from 0 to 2 that sum to 2 4 + 6 = 10 (poly^n #(X 1 1 1) 4) #(X 1 4 10 16 19 16 10 4 1) (1 + x 2)4
Generating Function Models for distributing 5 items into 4 bins Combination I/E x 0 1 * x 1 … x x 2 x 2 (x 0 + x 1 + x 2)4 Canonical patterns 0122 1112 0005 0014 0023 0113 e 1 + e 2 + e 3 + e 4 = 5 with 0 e 2 12 + 4 = 16 i Distribute/Select 5 identical items into/from 4 distinct bins with at most 2 items in each bin. 1111 111 x 2 11 x 1 11 xx 2 11 x 21 11 x 2 x 2 1 x 11 1 x 1 x 211 1 x 21 x 2 x 111 x 11 x 2 … (poly^n #(x 1 1 1) 4) #(X 1 4 10 16 19 16 10 4 1) (1 + x 2)4 (poly^n #(X 1 1 1) 4) #(X 1 4 10 20 35 56 80 104 125 140 146 140 125 104 80 56 35 20 10 4 1) rd 57
Generating Functions (1 + x)2 = (1 + x) = 11 + 1 x + x 1 + xx = 1 + 2 x + x 2 (1 + x)(1 + x) = 111 + 11 x + 1 x 1 1 xx + x 11 + x 1 x + xx 1 + xxx = 1 + 3 x 2 + 1 x 3 = (1 + x)3 is the generating function (poly^n #(x 1 1) 3) #(X 1 3 3 1) e 1 + e 2 + e 3 = 2; 0 ei 1 Canonical patterns: 011 3!/2! = 3 002 12/7/2020 rd 58
Selections with Repetition How many different orders can one create from 3 different types of fruit to get 6 pieces? (x 1 + x 2 + x 3 = 6 => 8 C 2) How many for 5 pieces? apple banana kiwi 0 ei 6 xx x xxx or 213 I. Canonical patterns: 006 015 024 033 114 123 222 3 6 6 3 3 6 1 = 28 II. (poly^n #(X 1 1 1 1) 3) (x 0 + x 1 + x 2 + x 3 + x 4 + x 5 + x 6 …)3 #(X 1 3 6 10 15 21 28) III. (comb 8 2) 28 x x | x ; 8 items; for 5 fruit: 005 014 023 113 122; (comb 7 2) =21 3 + 6 + 3 = 21 for 4 fruit 004 013 022 112 => 3 + 6 + 3 = 15 12/7/2020 rd 59
Generating Functions In the expansion of (1 + x 2)4 the sequence will have form where x 0 = 1 1111 111 x 2 11 x 1 … or xe 1 xe 2 xe 3 xe 4 0 ei 2 To find the coefficient where the sum of the exponents is 5 e 1 + e 2 + e 3 + e 4 = 5; 0 ei 2 (poly^n #(x 1 1 1) 4) #(X 1 4 10 16 19 16 10 4 1) Canonical: 0122 1112 => 12 + 4 = 16, Check out 0 to 8 and observe the answers are in the corresponding positions. Let Ai = {integer solutions with xi 3) N - N(Ai) = 56 - 40 12/7/2020 rd 60
Combinatorial Method x 1 + x 2 + x 3 + x 4 + x 5 = 19; 1 xi 6 and integer. (6 items) Compute the number of ways to roll 5 fair dice (bins) and obtain a sum of 19 or find number of integer solutions. (- (comb 18 4) (* (comb 5 1) (comb 12 4)) (- (* (comb 5 2) (comb 6 4)))) 735 = 3060 – 2475 + 150 canonical: 1666 2566 3466 3556 4456 4555 1 ei 6 Start with 19 + 4 bins = 23, take away 5 for at least 1 in each bin (no 0), then look at constraints of no integer higher than 6 and rule out > 6, and 77…, and note that can't have 777 > 19. (Exclusion/Inclusion) 1 xi 6 and integer (coef (poly^n #(x 0 1 1 1) 5) 19) 735 12/7/2020 rd 61
Generating Functions In the expansion of (1 + x 2)4 the sequence will have form where x 0 = 1 or xe 1 xe 2 xe 3 xe 4 0 ei 2 To find the coefficient where the sum of the exponents is 5 e 1 + e 2 + e 3 + e 4 = 5; 0 ei 2 (poly^n #(x 1 1 1) 4) #(X 1 4 10 16 19 16 10 4 1) Check out 0 to 8 and observe the answers are in the corresponding positions. Let Ai = {integer solutions with xi 3) in ith position For coefficient 8, canonical pattern is 2222 1 12/7/2020 N - N(Ai) = 165 – 224 + 60 = 1 rd 62
Marbles In a box are 4 marbles: 2 blue, 1 yellow, and 1 green. You randomly selected 2 and saw that one of them was blue. What is the probability that the other one is also blue? Seeing 1 B implies: Sample Space: B 1 B 2 B 1 G B 1 Y B 2 G B 2 Y YY, YG, GG Ans. 1/5 12/7/2020 rd 63
How Many Centuries in 20! Seconds? 60 * 24 * 365 * 100 = 3, 153, 600, 000 seconds/century 20! = 2, 432, 902, 008, 176, 640, 000 seconds (/ 2432902008176640000 3153600000) 7. 71468166 E 8 281585880576 / 365 = 771, 468, 166 centuries. (f 100) 100! 933262154439441526816992388562667004907159682643816214 685929638952175999932299156089414639761565182862536979 20827223758251185210916864000000000000 12/7/2020 rd 64
There are 10, 000 cars in a parking lot with license plate consisting of 3 letters followed by 4 numerals. No two cars have the same numerical designation. When the cars begin to leave, what is the probability that the first 5 cars leave in increasing numerical order? 12/7/2020 rd 65
Unique Integers 1. Consider unique 3 -digit integers formed from the set {0 to 9}, with neither leading zero, nor repetition of digit (sampling without replacement) Total Number = 9 * 8 = 648 a) How many are odd? 8 * 5 = 320 c) How many are even? Ending in 0: 9 * 8 * 1 = 72 Not Ending in 0: 8 * 4 = 256 328 d) How many end in 5? 8 * 1 = 64 e) How many unique integers are there in the first 1, 000 integers (0 to 999)? 1 -digit has 10; 2 -digit has 9 * 9 = 81, 3 -digit has 9 * 8 = 648; Thus 10 + 81 + 648 = 739 unique integers < 1000. f) How many 7's are there in the digits from 1 to 100? 10 + 10 = 20 1 to 100 0 to 99 => __ __ 1 to 1000? 12/7/2020 rd 66
Of 3 cards, one is red on both sides, another blue on both sides, and the third is red on one side and blue on the other. One is randomly selected and placed down showing a blue side. Find probability the other side is also blue. Hint: See pictures below. 12/7/2020 rd 67
5 -card Poker Compute probability of just 3 of one rank [xxx y z] P(triple) = 5 9 J 5 9 9 9 J 5 J 12/7/2020 rd 68
1. Compute the probability that the number on one die is twice the number on the other. 2[P(1, 2) + P(2, 4) +P(3, 6)] = 2 * (3/36) = 6/36 = 1/6. 2. Two cards are randomly selected from a deck of 52. Find the probability that both cards are between 4 and 9 exclusive. p = 16 C 2 / 52 C 2 = 0. 0905 3. On tossing a pair of fair dice, the probability that at least one face depicts a 5 or else the sum of the dice equals 5 is: p = [(1 – P(no fives)] + P(S 5) = (1 – 25/36) + 4/36 = 5/12. 12/7/2020 rd 69
4. Compute the probability of just one pair in 5 -card poker. [xx y z w] P(pair) = = 0. 423. On the fly (52/52)(3/51)(48/50)(44/49)(40/48)*[5!/2!1!1!1!3!] 5. If a fair coin is flipped n times, the probability p of showing the same face on all flips is p = 12/7/2020 rd 70
6. The probability p of 3 of any one suit and 2 of another in 5 -card poker is [xxx yy] p = = 0. 010 7. The probability of S 7 or S 11 before S 4 or S 6 in craps is p = 12/7/2020 rd 71
Birthday Problem 8. If 4 people each choose a number randomly from the set of whole numbers from 1 to 12, the probability that two or more people choose the same number is p = 1 - = 1 - 0. 5729 = 0. 4271. (- 1 (/ (perm 12 4) (expt 12 4))) 12/7/2020 rd 72
9. A closet contains 4 pairs of different shoes. If 5 shoes are randomly selected, calculate the probability that there will be (a) no complete pair, (b) exactly 1 complete pair, and (c) exactly 2 complete pairs a) P(0 pair) = 0 (pigeon-hole principle) [v w x y ? ] b) P(1 pair) = [ww x y z] c) P(2 pair) = [xx yy z] 12/7/2020 rd 73
10. Is it possible for the correct odds to be 5 : 3 that event A occurs, 2 : 1 that event B occurs, and 1 : 4 that both occur? Show work. P(A) = 5/8; P(B) = 2/3; P(AB) = 1/5 P(A + B) = P(A) + P(B) – P(AB) = 5/8 + 2/3 - 1/5 > 1 => not possible. 11. How many people would you have to ask before finding one with the same birthday as yours with probability 1/2? Make appropriate assumptions. 1 - 12/7/2020 = ½ => n = - 0. 693 / -0. 00274 = 253. rd 74
12. A poker player is dealt 3 hearts and 2 clubs. The player discards the 2 clubs and draws 2 more cards. Compute the probability that the player draws 2 more hearts. 13. The sum S 6 results from a pair of fair dice. Find the probability that at least one die shows a 3. Reduced space: (1, 5) (2, 4) (3, 3) (5, 1) (4, 2) => 1 – 4/5 = 1/5. P[(3, 3) |S 6] = P(3, 3)/P(S 6) = (1/36)/(5/36) 12/7/2020 rd 75
14. Compute the probability of S 12 in rolling 4 fair dice. # ways 12 6 24 24 12 12 4 12 6 1146 1155 1236 1245 1335 1344 2226 2235 2244 12 1 2334 3333 Count the ways: 1 + 1(4) + 2(6) + 5(12) + 2(24) = 125 p = 125 / 1296 = 0. 09645. (dice 12 4) (125 1296 0. 096451) or (canonical-dice 4) (coef (poly^n #(X 0 1 1 1) 4) 12) 125 #(X 0 0 1 4 10 20 35 56 80 104 125 140 146 140 125 104 80 56 35 20 10 4 1) 1 ei 6 (6 items) 12/7/2020 rd 76
15. 5 -card poker P(4 aces) = P(4 of a rank) = [xxxx y] P(4 of a rank on fly) = P(4 aces on fly) = 12/7/2020 rd 77
16. Compute the probability of 2 pairs in 5 -card poker on the fly. [xx yy z]. Check the swapping of the two pairs accounting for the /2! Term. 12/7/2020 rd 78
17. Find the probability that a randomly chosen integer from 1 to 1000 is divisible by 3 or 5 given that it is divisible by 2. P[(D 3 + D 5)| D 2] = = 12/7/2020 rd 79
5 -card Poker with No Void in any Suit How many ways can a 5 -card poker hand be selected with all suits present? Let A be no clubs, B no diamonds, C no hearts and D no spades. Then N(ABCD) = N – N(A + B + C + D) = 675, 168 12/7/2020 rd 80
Compute the probability of rolling 5 dice and getting exactly 2 pair and nothing more. [xx yy z] 2 4 5 | 22 44 5 | _ _ x _ _ P(2 pair) = . On the fly: xx yy z Account for the three 2!’s in the denominator. 12/7/2020 rd 81
Hats Back aka Fixed Points What is the probability of a random selection of n checked hats producing no correct hat back? N = n! and let Ai be the set of outcomes where i gets his hat back. 12/7/2020 rd 82
Expected Value of Fixed Points What is the expected value of the number of fixed points in a permutation of a set of numbers, e. g. say 5. X 0 1 2 3 4 5 # 44 45 20 10 0 1 P(X) 11/30 3/8 1/6 1/12 0 1/120 E(X) = (+ 3/8 2/6 3/12 5/120) 1 (123) (* (comb 5 2) (derange 3)) = 20 for 2 fixed points 12/7/2020 rd 83
Generating Function Models Combination 1 1 x * x … x 2 (x 0 + x 1 + x 2)4 Canonical patterns 0122 1112 e 1 + e 2 + e 3 + e 4 = 5 with 0 ei 2 12 + 4 = 16 Selecting 5 objects from a collection of 4 types with at most 2 of each type. Distributing 5 identical objects into 4 distinct bins with at most 2 objects in each bin. (poly^n #(x 1 1 1) 4) #(X 1 4 10 16 19 16 10 4 1) 12/7/2020 rd 84
Software Exercises (sim-doors) (sim-poker) (print-map 50) ; matches and derangements (permutation-list '(plum orange bell) 3) (sim-poker-dice 1000) (count-1 -pair (sim-poker-dice 1000)) (P-1 -fruit plum 1000) (sim-slot-machine 1000) (sim-h-vs-t '(T T H) '(T H T) 1000) (sim-paradox-wr 1000) (sim-urn-wr 700 1200) (bet 64 '(1 0 0 0 1 1) 1/2) (sim-double-bet 1000) (print-count-a-b 0 9 pi-2500) (pick-until 2007 10000) (derange 5) 5! e-1 12/7/2020 rd 85
Types of Proofs 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 12/7/2020 Direct proofs Indirect proofs Vacuous proofs to be or not to be Trivial proofs me and mike 18 = 2 Proof by contradiction; finite primes Proof by cases (x 2 – 5 x + 6) < 0 Proofs of equivalence Existence proofs Uniqueness proofs Counterexamples rd 86
Kraitchik's/Newcomb's Two Box Paradox Wallet Paradox In one box is $x and in the other $2 x. You choose a box and see the contents and then can decide whether to take the contents of the other box. You see $? Not knowing sets the reference at X. E(X) = ½(2 x) + ½ (x/2) = 5 x/4 > X => switch Then without looking, re-evaluate back. 12/7/2020 rd 87
Golden Ratio x 2 – x - 1 = 0 (quadratic 1 -1 -1) 1. 618034, -0. 618034 12/7/2020 rd 88
Matrix Fibonacci (expt-mat #2 A((0 1)(1 1)) 5) #2 A((3 5)(5 8)) The determinant is (-1)n 3 5 5 8 (expt-mat #2 A((0 1)(1 1)) 6) #2 A((5 8)(8 13)) (expt-mat #2 A((0 1)(1 1)) 7) #2 A((8 13)(13 21)) . . . 12/7/2020 rd 89
Elementary Cellular Automata 2^8 = 256 rules Rigid array Parallel update 7 6 5 4 3 2 1 0 12/7/2020 rd 90
Class 1 – Repetition Degenerate, single color or checker board Nothing really interesting or surprising Rule 250 12/7/2020 rd 91
Class 2 – Nesting Repeated nested patterns Rule 90 12/7/2020 rd 92
Class 3 – Randomness 10 rules of elementary CA are random Statistical analysis show randomness Are purely random patterns less complex than localized structures? Rule 30 12/7/2020 rd 93
Class 4 – Localized Structures Neither regular nor completely random Unique rule among 256 elementary CA Rule 110 12/7/2020 rd 94
Elementary cellular automata rule 222 12/7/2020 rd 95
Elementary cellular automata rule 222 12/7/2020 rd 96
Elementary cellular automata rule 94 12/7/2020 rd 97
Elementary cellular automata rule 94 12/7/2020 rd 98
Elementary cellular automata rule 90 12/7/2020 rd 99
Elementary cellular automata rule 90 12/7/2020 rd 100
Emergence of life. Communities Atom Organisms Molecule Tissue Cell 12/7/2020 rd Organs 101
Simulation On each face-down card in a deck of 52 is a randomly selected positive integer. If the last card you turn over when you stop is the largest in the deck, you win. You can stop at any time. You win $50 but it costs $10 to play. Are you game? (setf ss (swr 52 (upto 10000))) Split deck in two and turn over first half and find the maximum. Then stop on the second half as soon as one is found exceeding the max of the first half. Soul Mate? 12/7/2020 rd 102
Pascal’s Triangle n = 0 1 2 3 4 5 6 7 8 rd 12/7/2020 103
How Many? How many 5's are there in the numerals from 1 to 100, 000? Leading 0's allowed. 1 * 10*10*10*10 * 5 = 50, 000 5's How many 7's in the integers from 1 to 100? 20 1 to 1000? 300 ___ (1 * 10) + (10 * 1) ___ ___ (1 * 10) + (10 * 1) 12/7/2020 rd 104
Inclusion-Exclusion N A 12/7/2020 AB B rd 105
Example 6 How many positive integers 70 are relatively prime to 70? Inclusion/Exclusion Principle 2 * 5 * 7 = 70 (A is / by 2 B is / by 5 and C is by 7) N - N(A B C) = 70 – (35 + 14 + 10)2, 5, 7 + 710 + 514 + 235) – 170 = 24 (rel-prime<n 70) (1 3 9 11 13 17 19 23 27 29 31 33 37 39 41 43 47 51 53 57 59 61 67 69) (length *) 24 12/7/2020 rd 106
Smallest Integer Find the probability that 8 is the smallest integer, from 4 randomly chosen integers in interval [1 20]. Repeat for 2 nd smallest. (9, 10, … 20) (/ (comb 12 3) (comb 20 4)) 44/969 (/ (* (comb 7 1) 1 (comb 12 2)) (comb 20 4)) 154/1615 12/7/2020 rd 107
Phone Combinatorics Compute the probability that a 4 -digit phone number has one or more repeated digits. By cases: [xxxx] [xxxy] [xxyz] Total = 10 + 360 + 270 + 4320 = 4960 Complement: Numerals all different is 10 * 9 * 8 * 7 = 5040 ways => the probability with repeated digits is 0. 4960. 12/7/2020 rd 108
Different Equivalent Methods How many different integer solutions are there to the equation e 1 + e 2 + e 3 + e 4 + e 5 + e 6 = 20; 0 ei 8? N = (comb (+ 20 6 -1) 5) = 53, 130 without any restriction. Inclusive/Exclusive N(Ai) with x 9; 9 *****; 9 + 0 + 1 + 1 e. g. N(A 1 A 2 A 3 A 4 A 5 A 6) = Canonical Patterns 000488 000578 000668 000677 001388 … Generating Functions (coef (poly^n #(X 1 1 1 1 1) 6) 20) 27237 12/7/2020 rd 109
Fibonacci Sequence Recursive – up a staircase one or two steps at a time with n steps n # of ways 1 1 2 2: 1, 2 3 3: 111, 12, 21 4 5: 1111, 112, 121, 211, 22 fn = fn-1 + fn-2 For n = 5 steps, take 1 step 4 5 ways 11111, 1112, 1121, 1211, 122 thereafter or 2 steps 3 3 ways 2111, 212, 23 thereafter yielding 5 + 3 = 8 12/7/2020 rd 110
The pigeonhole principle • Suppose a flock of pigeons fly into a set of pigeonholes to roost • If there are more pigeons than pigeonholes, then there must be at least 1 pigeonhole that has more than one pigeon in it • If k+1 or more objects are placed into k boxes, then there is at least one box containing two or more of the objects CSci 2011 Fall 2008
Pigeonhole principle examples In a group of 367 people, there must be at least two people with the same birthday since there are 366 possible birthdays (leap year). |367/366| > 1 => 2 In a group of 27 English words, at least two words must start with the same letter; as there are only 26 starting letters. |27/26| > 1 => 2 CSci 2011 Fall 2008
Generalized pigeonhole principle If N objects are placed into k boxes, then there is at least one box containing N/k objects. 27 playing cards imply at least how many suits present? Ans. at least 3 and at least 1 of the 3 suits containing at least 9 cards. [27/2] > 13 [27/3] = 9 CSci 2011 Fall 2008
Generalized pigeonhole principle Among 100 people, there at least 100/12 => at least 9 born in the same month How many students in a class must there be to ensure that 6 students get the same grade (one of A, B, C, D, or F)? The “boxes” are the grades. Thus, k = 5 Thus, we set N/5 = 6; solve for N Lowest possible value for N is 26
Example A bowl contains 10 red and 10 yellow balls. How many balls must be selected to ensure 3 balls of the same color? One solution: consider the “worst” case Consider 2 balls of each color [N/2] = 3; solve for N You can’t take another ball without getting 3, Thus, the answer is 5 Via generalized pigeonhole principle How many balls are required if there are 2 colors, and one color must have 3 balls? [N/2] = 3; solve for N How many pigeons are required if there are 2 pigeon holes, and one hole must have at least 3 pigeons? 5 [N/2] = 3
Cases How many ways to put 5 red, 6 blue and 7 green marbles into 2 containers without restriction? Red: (comb 6 1) x 1 = 6 x 1 + x 2 = 5 Blue: (comb (7 1) x 2 = 7 Green: (comb 8 1) x 3 = 8 Thus 6 * 7 * 8 = 336 12/7/2020 rd 116
Matches in a Deck of Cards Lay 2 shuffled decks side by side and pick cards from each to determine how many matches one would expect. Ans: 52 * 1/52 = 1 match of rank and suit. Try the Genie command (print-map 3) and determine the expected values of the matches. Repeat for 4 and 5 to get the drift. 12/7/2020 rd 117
Prisoner's Dilemma Ordered pair (you, me) of years in prison ME Stay Mum Confess YOU Stay Mum (2, 2) (5, 0) Confess (0, 5) (4, 4) You 2 5 0 4 0 < 2 and 4 < 5 => Confess Me 2 0 0 < 2 5 4 4 < 5 => Confess to get (Lose, Lose) OB 6– 118
Cross Entropy X P(X) m 1 M 2 A B 0. 4 0. 1 0. 25 0. 4 0. 1 C 0. 25 0. 1 D 0. 25 0. 4 Which better matches the RV X distribution, m 1 or M 2? (Mapcar #' entropy '((0. 4 0. 1 0. 25)(0. 4 0. 1 0. 4))) (1. 860964, 2. 0 1. 721928) 12/7/2020 rd 119
- Slides: 119