Counting and Probability

Random: (Merriam-Webster) being or relating to a set or to an element of a set each of whose elements has equal probability of occurrence <a random sample>; also: characterized by procedures designed to obtain such sets or elements <random sampling>.

Sample space: the set of all possible outcomes of a random process or experiment. An event is a subset of a sample space.

In case an experiment has finitely many outcomes and all outcomes are equally likely to occur, the probability of an event (set of outcomes) is just the ratio of the number of outcomes in the event to the total number of outcomes. Stated as a principle:

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

Probability of an Event

The cardinality of a set A is denoted |A| or as n(A). With this notation the equally likely probability formula becomes

probability of an event formula

Example 6.1.1 Probabilities for a Deck of Cards

An ordinary deck of cards contains 52 cards divided into four suits. The red suits are diamonds (¨ ) and hearts (© ) and the black suits are clubs (§ ) and spades (ª ). Each suit contains 13 cards of the following denominations: 2, 3, 4, 5, 6, 7, 8, 9, 10, J (jack), Q (queen), K (king), and A (ace). The cards J, Q, K, and A are called face cards.

  1. What is the sample space of outcomes, S?
  2. What is the event, E, that the chosen card is a black face card?
  3. What is the probability that the chosen card is a black face card?

Solution:

  1. S = 52.
  2. E = {J§ , Q§ , K§ , A§ , Jª , Qª , Kª , A ª }
  3. P(E) = |E| / |S| = 8 / 52 » 15.4%.

Example 6.1.2 Rolling a Pair of Fair Dice

We can use compact notation to indicate the outcome of the toss of a pair of fair dice, each of which can roll as 1, 2, 3, 4, 5, or 6. So for two die with outcomes of say 3 and 4 we could write compactly as 34.

  1. Use compact notation to write out S.
  2. Use set notation to write the set E that the numbers showing face up have a sum of 6.
  3. Find P(E).

Solution:

  1. S = {11, 12, 13, 14, 15, 16, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 45, 46, 51, 52, 53, 54, 55, 56, 61, 62, 63, 64, 65, 66}.
  2. E = {15, 24, 33, 42, 51}.
  3. P(E) = |E| / |S| = 5 / 36.

Counting Elements in a List

If m and n are integers and m £ n, how many integers are there from m through n? The first element in the list is m and the last is n. Since the list is inclusive, we have m – n + 1 elements in our integer list. This simple but significant result is stated as a theorem:

Theorem 6.1.1 The Number of Elements in a List

If m and n are integers and m £ n, then there are n – m + 1 integers from m to n inclusive.

Example 6.1.3 Counting the Elements of a Sublist

  1. How many three-digit integers (integers from 100 to 999 inclusive) are divisible by 5?
  2. What is the probability that a randomly chosen three- digit integer is divisible by 5?

Solution

100

101

102

103

104

105

995

996

997

998

999

5(20)

       

5(21)

5(199)

       
  1. From the table it is clear that there are as many three-digit integers that are multiples of 5 as there are integers from 20 to 199 inclusive. E = 199 – 20 + 1 = 180.
  2. probability of the three digit integers being divisible by 5 Or 20%.

Example 6.1.4 Counting Elements of a One-Dimensional Array

Analysis of many computer algorithms requires skill at counting the elements of a one-dimensional array.

  1. Suppose the array A[1] … A[n] is divided into two subarrays at A[m]. How many elements are in each subarray?
  2. What is the probability that a randomly chosen element of the array has an even subscript?

Solution

  1. The subarray A[1] … A[m] has exactly m elements, (m – 1 + 1). The subarray A[m +1] … A[n] has n m elements, (n (m + 1) + 1).
  2. Consider the table below, n is either even or odd:

1

2

3

4

5

n - 1

n

Parity

 

2 (1)

 

2 (2)

 

 

2 (n/2)

even

 

2 (1)

 

2 (2)

 

2 (n – 1)/2

 

odd

In the "even n" case P(E) = |E|/|S| = (n / 2) / n = ½.

In the "odd n" case P(E) = |E|/|S| = ((n – 1) / 2) / n = (n – 1) / 2n.

In either case P(E) = ë n / 2û / n.