Skip to main content

Sampling with replacement

Let us consider two examples. Benjawan found a nice chocolate shop that sells 1010 kinds of chocolates. In the first example, Benjawan wants to buy a chocolate for each of the four best performing students in this class. How many possibilities does she have? The answer is clearly 10410^4: a chocolate for each student can be picked in 1010 ways. In another scenario, Amelia forgot her PIN code for entering the CS building. The PIN is four digits long. How many possibilities does she need to go through before she tries all possibilities? Again, the answer is 10410^4 (each digit is between 00 and 99, so ten possibilities). This type of counting arises in many scenarios in real life, and many of us end up doing it and believing immediately that our calculation is correct.

But is there any formal proof that such a calculation is correct? Let us try to make a general theorem out of it.

Theorem 22

Let NN be an nn-element set and MM be an mm-element set. The number of possible mappings f:NMf: N \rightarrow M is mnm^n.

Exercise 57

Prove Theorem 22 by induction on n1n \geq 1.

Notice that our previous counting problems can be reduced to the theorem. Amelia's PIN is just a mapping f:{1,2,3,4}{0,,9}f:\{1,2,3,4\} \rightarrow \{0,\ldots, 9\} where f(i)f(i) is the value of the ii-th digit. Benjawan's chocolate selection is the same: It is just the number of functions f:{s1,s2,s3,s4}{c1,,c10}f: \{s_1,s_2,s_3,s_4\} \rightarrow \{c_1,\ldots, c_{10}\} where sis_i is the ii-th ranked student and cjc_j is the chocolate of type jj. The mapping f(s2)=c3f(s_2) = c_3 means that the second-ranked student gets the third type of chocolate. Therefore, one may view Theorem 22 as a formal proof in support of counting methods that we have been using all along (e.g., another famous example is that tossing a dice kk times results in 6k6^k possibilities).

The next claim is well known to almost everyone, but how many of us actually prove it at least once in our life?

Theorem 23

Any nn-element set XX has exactly 2n2^n subsets.

Proof:

Notice that every subset AXA \subseteq X can be represented by a function χA:X{0,1}\chi_A:X \rightarrow \{0,1\} where χA(x)=1\chi_A(x) = 1 if xAx \in A and χA(x)=0\chi_A(x) = 0 otherwise. Therefore, counting the number of subsets of XX is the same as counting the number of functions χA\chi_A. From the theorem, we have 2n2^n such functions.

One should remark a small gap in the above argument: We take it for granted that the number of functions χA\chi_A is the same as the number of subsets of XX. In this case, it is relatively straightforward to see. In particular, showing that two sets YY and ZZ have exactly the same cardinality can be done by defining a bijection f:YZf: Y \rightarrow Z.

Definition 1

A function f:XYf: X \rightarrow Y is called

  • one-to-one if xyx \neq y implies f(x)f(y)f(x) \neq f(y),
  • onto if for all yYy \in Y, there exists xx such that f(x)=yf(x) = y, and
  • bijection if it is one-to-one and onto.

Bijection often comes in handy as a tool for counting.

Exercise 58

Prove that the function mapping from AA to χA\chi_A is a bijection.

Exercise 59

Prove Theorem 23 by induction on nn.

Example 21

Let n1n\geq 1. Each nn-element set XX has exactly 2n12^{n-1} subsets of odd size.

Proof:

Let O\mathcal{O} and E\mathcal{E} be the family1 of subsets of XX of odd and even sizes respectively. Define a bijection f:OEf: \mathcal{O} \rightarrow \mathcal{E} as follows. Fix element aXa \in X. Define f(A)=A{a}f(A) = A - \{a\} if aAa \in A and f(A)=A{a}f(A) = A \cup \{a\} otherwise. Function ff is one-to-one since f(A)=f(B)f(A) = f(B) implies that A=BA=B and onto since every set AEA \in \mathcal{E} is mapped from either A{a}A - \{a\} (when aAa \in A) or from A{a}A \cup \{a\} (when a∉Aa \not\in A). (do you see how this concludes the proof?).

Exercise 60

Present an alternate proof of the above example by defining a bijection between O\mathcal{O} and {A:AX{a}}\{A: A \subseteq X \setminus \{a\}\} (the latter set has 2n12^{n-1} elements from Theorem 23).

Footnotes

  1. This is just a fancy name to say that we are referring to a "set of sets".