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
![]()
The cardinality of a set A is denoted |A| or as n(A). With this notation the equally likely probability formula becomes
![]()
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.
Solution:
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.
Solution:
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
Solution
|
100 |
101 |
102 |
103 |
104 |
105 |
… |
995 |
996 |
997 |
998 |
999 |
|
5(20) |
5(21) |
… |
5(199) |
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.
Solution
|
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.