Spring 2016 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 9.1 Counting and Probability
Sample Space A sample space is the set of all possible outcomes of a random process or experiment. An event is a subset of a sample space. Example Tossing Two Coins Possible outcomes: FF, FT, TF, TT Sample space: {FF, FT, TF, TT} 2 Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University
Equally Likely Probability Formula If S is a finite sample space in which all outcomes are equally likely and E is an event in S, then the probability of E, denoted P( E ), is For any finite set A, N ( A ) denotes the number of elements in A. 3 Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University
Equally Likely Probability Formula – cont’ Example Tossing Two Coins What is P( E =“One head, one tail”)? 4 Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University Coin 1Coin 2 TT TH HT HH
Rolling a Pair of Dice Suppose we are rolling a pair of dice. Use the compact notation to write the sample space S of possible outcomes. Use set notation to write the event E that the numbers showing face up have a sum of 6 and find the probability of this event. 5 Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University
Rolling a Pair of Dice – cont’ Suppose we are rolling a pair of dice. Use the compact notation to write the sample space S of possible outcomes. Use set notation to write the event E that the numbers showing face up have a sum of 6 and find the probability of this event. 6 Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University
Counting the Elements of a List Theorem The Number of Elements in a List If m and n are integers and, then there are n-m +1 integers from m to n inclusive. Examples How many integers are there from m =5 through n= 12? 5 ( m +1-1), 6( m +2-1), 7( m +3-1), 8( m +4-1), 9( m +5-1), 10( m +6-1), 11( m +7-1), 12( m +8-1), where 8 = n - m +1. How many three digit integer (100~999) are divisible by 5? … = Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University
Application: Counting Elements of a One-Dimensional Array Analysis of many computer algorithms requires skill at counting the elements of a one-dimensional array. Let A [1], A [2], …, A [ n ] be a one-dimensional array, where n is a positive integer. 1)Suppose the array is cut at a middle value A [ m ] so that two subarrays are formed: A [1], A [2], …, A [ m ] and A [ m +1], A [ m +2], …, A [ n ]. How many elements does each subarray have? 2)What is the probability that a randomly chosen element of the array has an even subscript I.If n is even? II.If n is odd? 8 Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University
Application: Counting Elements of a One-Dimensional Array Analysis of many computer algorithms requires skill at counting the elements of a one-dimensional array. Let A [1], A [2], …, A [ n ] be a one-dimensional array, where n is a positive integer. 1)Suppose the array is cut at a middle value A [ m ] so that two subarrays are formed: A [1], A [2], …, A [ m ] and A [ m +1], A [ m +2], …, A [ n ]. How many elements does each subarray have? : m -1+1 = m and n -( m +1)+1 = n - m 2)What is the probability that a randomly chosen element of the array has an even subscript I.If n is even? II.If n is odd? 9 Spring 2016 COMP 2300 Department of Mathematics and Physics Donghyun (David) Kim North Carolina Central University