Arrangements and Selections (and how they may be counted)

Slides:



Advertisements
Similar presentations
4/16/2015 MATH 224 – Discrete Mathematics Counting Basic counting techniques are important in many aspects of computer science. For example, consider the.
Advertisements

Chapter 8 Counting Principles: Further Probability Topics Section 8.3 Probability Applications of Counting Principles.
Describing Probability
CSCE 2100: Computing Foundations 1 Combinatorics Tamara Schneider Summer 2013.
16.4 Probability Problems Solved with Combinations.
Counting Principles The Fundamental Counting Principle: If one event can occur m ways and another can occur n ways, then the number of ways the events.
1 Counting Rules. 2 The probability of a specific event or outcome is a fraction. In the numerator we have the number of ways the specific event can occur.
1 Counting Rules. 2 The probability of a specific event or outcome is a fraction. In the numerator we have the number of ways the specific event can occur.
1 Probability Parts of life are uncertain. Using notions of probability provide a way to deal with the uncertainty.
1 Section 5.1 Discrete Probability. 2 LaPlace’s definition of probability Number of successful outcomes divided by the number of possible outcomes This.
Intro to Probability & Games
1 The game of poker You are given 5 cards (this is 5-card stud poker) The goal is to obtain the best hand you can The possible poker hands are (in increasing.
Probability – Models for random phenomena
Chapter 11: Counting Methods
Counting. Techniques for counting Rule 1 Suppose we carry out have a sets A 1, A 2, A 3, … and that any pair are mutually exclusive (i.e. A 1  A 2 =
6.1 Probability exercises. Def Def: If S is a finite sample space of equally likely outcomes, and E is an event, that is, a subset of S, then the probability.
Chapter 10: Counting Methods
10.3 – Using Permutations and Combinations Permutation: The number of ways in which a subset of objects can be selected from a given set of objects, where.
Chapter  Determine how many different possibilities are possible:  1. There are 3 different ice cream flavors and 5 different toppings. You.
15.3 Counting Methods: Combinations ©2002 by R. Villar All Rights Reserved.
Homework Homework due now. Reading: relations
MA-250 Probability and Statistics Nazar Khan PUCIT Lecture 15.
Expected Value. Expected Value - Definition The mean (average) of a random variable.
Draw 3 cards without replacement from a standard 52 card deck. What is the probability that: 1.They are all red ? 2.At least one is black ? 3.They are.
Some other set notation We will use the notation to mean that e is an element of A. We will use the notation to mean that e is not an element of A.
Algebra-2 Counting and Probability. Quiz 10-1, Which of these are an example of a “descrete” set of data? 2.Make a “tree diagram” showing all.
Chance We will base on the frequency theory to study chances (or probability).
Quiz: Draw the unit circle: Include: (1)All “nice” angles in degrees (2) All “nice” angles in radians (3) The (x, y) pairs for each point on the unit circle.
Probability and statistics - overview Introduction Basics of probability theory Events, probability, different types of probability Random variable, probability.
Texas Holdem A Poker Variant vs. Flop TurnRiver. How to Play Everyone is dealt 2 cards face down (Hole Cards) 5 Community Cards Best 5-Card Hand Wins.
13 Lesson 1 Let Me Count the Ways Fundamental Counting Principle, Permutations & Combinations CP Probability and Statistics FA 2014 S-ID.1S-CP.3S-CP.5.
Section 6.3. Section Summary Permutations Combinations.
Probability Intro. Coin toss u Toss two coins 10 times keeping track of the results (head/tails) u Now toss 3 coins 10 times u Make a chart of all the.
How selections can be counted with Pascal's Triangle.
PROBABILITY AND STATISTICS WEEK 2 Onur Doğan. Introduction to Probability The Classical Interpretation of Probability The Frequency Interpretation of.
1 COMP2121 Discrete Mathematics Principle of Inclusion and Exclusion Probability Hubert Chan (Chapters 7.4, 7.5, 6) [O1 Abstract Concepts] [O3 Basic Analysis.
Fundamentals of Probability
Counting Principles Ex. Eight pieces of paper are numbered 1 to 8 and placed in a box. One piece of paper is drawn from the box, its number is written.
L14: Permutations, Combinations and Some Review
The Pigeonhole Principle
Developing Your Counting Muscles
What Is Probability?.
11.9: Solving Probability Problems by Using Combinations
CSE15 Discrete Mathematics 04/19/17
Algebra 2/Trig Name: ________________________
Combinations Problems
Chapter 4 Probability Concepts
COCS DISCRETE STRUCTURES
Section Combinations (with and without restrictions)
11/7/16 Entry 173 – Objective I will review and continue developing my understanding of uniform probability models, including the complement of an event.
The Counting Principle
Chapter 10: Counting Methods
Probability Probability underlies statistical inference - the drawing of conclusions from a sample of data. If samples are drawn at random, their characteristics.
Suppose you flip a fair coin twice
Permutations and Combinations
Basic Counting.
Combination and Permutations Quiz!
Basic Counting Lecture 9: Nov 5, 6.
How many possible outcomes can you make with the accessories?
Probability Problems Solved with
Section 12.2 Theoretical Probability
CHAPTER 5 Probability: What Are the Chances?
Using Permutations and Combinations
Bellwork Practice Packet 10.3 B side #3.
Section 12.2 Theoretical Probability
Applied Combinatorics, 4th Ed. Alan Tucker
Using Permutations and Combinations
Section 12.2 Theoretical Probability
10.3 – Using Permutations and Combinations
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

Arrangements and Selections (and how they may be counted)

Running our 'megawin.py' demo Last time we described the idea for a Python program that would compute the probability of winning the MegaMillions lottery jackpot It was based on a 'recursive' implementation for the function that computes binomial coefficients 0, if n<0 or k<0 or n<k b(n;k) = 1, if n==0 or k==0 or n==k b(n-1;k-1) + b(n-1;k), otherwise {

Let's take time now to execute this demo $ python megawin.py _______________________________________ NOTE: We can use the 'time' command to find out how long it takes to execute this program: $ time python megawin.py

Output from 'megawin.py'

has the potential for faster execution Can we get 'speedup'? A formula for evaluating binomial coefficients without resort to recursive function-calls has the potential for faster execution

Special case: binomial(56;5) Let's first consider counting all arrangements of 5 integers selected from { 1, 2, 3, ... , 56 } By an 'arrangement' we mean a way of listing the five selected numbers in some definite order, without repetitions or omissions Example-selection: { 1, 2, 3, 4, 5 } Then two possible arrangements are: ( 5, 4, 3, 2, 1 ) and ( 2, 4, 1, 3, 5 )

The number of arrangements There is more than one way to organize the counting of all the arrangements of 5 integers selected from the set { 1, 2, 3, ... , 56 } Method #1: we make the ordered list directly Method #2: we first select the 5-member subset, then we arrange its members in an ordered list

Method #1 ( __, __, __, __, __ ) 56 ways to choose the 1st integer 55 ways to choose the 2nd integer 54 ways to choose the 3rd number 53 ways to choose the 4th number 52 ways to choose the 5th number By FCP the total number of arrangements will be 56 x 55 x 54 x 53 x 52

Method #2 ( __, __, __, __, __ ) First select the 5-member subset b(56;5) represents the number of ways to do it Then arrange these selected integers 5 x 4 x 3 x 2 x 1 = number of ways to do that There are b(56;5) x 5! ways to do both tasks

The two answers must be equal b(56;5) x 5x4x3x2x1 = 56x55x54x53x52 (method #2 answer) (method #1 answer) From this equality we can infer that b(56;5) = 56x55x54x53x52 / 5x4x3x2x1 Or more simply: b(56;5) = 56! / (5! x 51!)

General formula for b(n;k) The same ideas we just employed lead us to a general formula for binomial coefficients: b(n;k) = n! / k! (n-k)! So this is the number of ways of choosing k integers from a set containing n integers (i.e., the number of k-element subsets of {1,...,n}

Applying formula in Python program def binomial( int n, int k ): num = 1 den = 1 for j in range( n ): num *= (n – j) den *= (k – j) return num / den _______________________________________ (Trouble if n or k is negative or zero -- or equal)

Our Python code

Output from 'megawin2.py' So this revised version of our 'megawin' program ran more than 250 times faster!

Poker hands In the game of 'poker' a player is dealt 5 cards selected from a 'shuffled' deck of 52 cards How many different poker hands are possible? The answer is another binomial coefficient: b(52;5) = 52x51x50x49x48 / 5x4x3x2x1

Evaluating without a computer Look for 'common factors' that can be cancelled: (52)(51)(50)(49)(48) ((13)(4))((17)(3))((10)(5))(49)((24)(2)) ---------------------------- = -------------------------------------------------- (5)(4)(3)(2)(1) (5)(4)(3)(2)(1) = (13)(17)(10)(49)(24) = (221)(10)(1176) = 2598960 So more than two-and-a-half million different poker hands are possible

Royal Flush The highest ranking poker hand is one with 'ace', 'king', 'queen', 'jack', 'ten' in a single suit (i.e., 'hearts', 'spades', 'diamonds' or 'clubs') What are your chances of being dealt a 'Royal Flush'? Answer: 4 chances in 2598960 (or 1 chance in 649740)

One Pair This is a poker hand in which exactly two cards have the same face-value (i.e., a 'pair') while the other three cards have three other face-values How likely is this type of poker hand? Answer: This probability is given by b(13;1) x b(4;2) x b(12;3) x b(4;1)3 / b(52;5)

Personal Identification Numbers Suppose you are asked to select a PIN that consists of 4 different uppercase letters How many choices do you have? Answer: b(26;4) x 4! (= 26! / 22!) If you choose a PIN at random, what are your chances of including just one vowel (A,E,I,O,U)?

Solution #1 ( __, __, __, __ ) First choose your vowel: b(5;1) ways to do it Next choose 3 consonants: b(21;3) ways to do it Then decide their ordering: 4! ways to do it Apply the Fundamental Counting Principle probability = b(5;1)*b(21;3)*4! / b(26;4)*4!

Solution #2 ( __, __, __, __ ) First decide where your vowel goes: b(4;1) ways Then decide which vowel to use: b(5;1) ways Now pick your consonants, in left-to-right order: 21 choices for 1st consonant 20 choices for 2nd consonant 19 choices for 3rd consonant probability = 4x5x21x20x19 / 26x25x24x23

Are these answers equal? Answer #1: b(5;1)xb(21;3)x4! / b(26;4)x4! Answer #2: 4x5x21x20x19 / 26x25x24x23

Successive repetition If you toss a coin n times, what are the chances of getting the same side twice in succession? Answer: 2 chances in 2n why? HINT: It's often easier to count outcomes in the complementary event