Lecture from: 18.03.2025 | Video: Homelab

Introduction

In our previous discussions, we’ve seen glimpses of how randomness can be a powerful tool in algorithm design (e.g., QuickSort, primality testing, cryptography, distributed computing). To rigorously analyze and understand such algorithms, we need a solid foundation in probability theory. This lecture introduces the basic building blocks: probability spaces, events, and fundamental rules for calculating probabilities.

Probability Space (Wahrscheinlichkeitsraum)

The mathematical framework for dealing with randomness is the probability space.

Definition 2.1: Discrete Probability Space

A discrete probability space is defined by:

  1. Sample Space (Ergebnismenge) : This is the set of all possible outcomes of a random experiment. We denote these outcomes as elementary events (Elementarereignisse). For a discrete space, is countable:

  2. Probability Assignment (Wahrscheinlichkeit): Each elementary event is assigned a probability . This assignment must satisfy two conditions:

    • Non-negativity: for all . (Probabilities are between 0 and 1, inclusive).
    • Normalization: The sum of probabilities of all elementary events must equal 1:

Events (Ereignisse)

An event (Ereignis) is any subset of the sample space , i.e., . An event represents a collection of possible outcomes.

The probability of an event , denoted , is the sum of the probabilities of all elementary events contained within :

Complementary Event (Komplementärereignis)

If is an event, its complementary event, denoted , consists of all elementary events in that are not in . Formally:

Example: Rolling a Die (Betrachte Würfel)

Consider the simple experiment of rolling a standard six-sided die.

  • Sample Space: The possible outcomes are the numbers 1 through 6.

  • Probability Assignment: Assuming a fair die, each outcome is equally likely. Note: and .

  • Events: Let’s define some events:

    • : “The result is even” (Augenzahl ist gerade).
    • : “The result is a prime number” (Augenzahl ist Primzahl).
    • : “The result is divisible by 6” (Augenzahl ist durch 6 teilbar).

Basic Properties of Probability

From the definition of a probability space, several fundamental properties follow.

Lemma 2.2: Properties of Events

For any events in a probability space :

  1. Empty Set and Sample Space:

    • (The probability of the impossible event is 0).
    • (The probability of the certain event is 1).
  2. Bounds: .

  3. Complement Rule: . (The probability of an event not happening is 1 minus the probability that it does happen).

  4. Monotonicity: If , then . (If event A implies event B, then the probability of A cannot exceed the probability of B).

  5. Addition Rule for Disjoint Events (Additionssatz): If events are pairwise disjoint (meaning for all ), then the probability of their union is the sum of their individual probabilities: This rule also extends to a countably infinite collection of pairwise disjoint events:

Union of Events (Vereinigung von Ereignissen)

What happens when events are not disjoint? The simple addition rule no longer applies directly.

Example: Dice (Continued)

Consider events and from the dice example. These are disjoint (). Their union is . Using the addition rule for disjoint events: . This works.

Now consider events and . These are not disjoint, as . Their union is . If we incorrectly use the simple addition rule: . This is incorrect because we double-counted the outcome , which is in both and .

Boole’s Inequality (Union Bound)

For any (not necessarily disjoint) events , the probability of their union is less than or equal to the sum of their individual probabilities.

Satz 2.4 (Boolesche Ungleichung):

This is also known as the union bound. It provides a simple upper bound for the probability of a union, which is often useful even if it’s not exact.

Principle of Inclusion-Exclusion (Siebformel)

To calculate the exact probability of the union of non-disjoint events, we use the Principle of Inclusion-Exclusion (PIE), also known as the Sieve Formula (Siebformel).

Satz 2.3 (Siebformel, Prinzip der Inklusion/Exklusion): For any events (where ):

Explanation: The formula starts by summing all individual probabilities. Then, it subtracts the probabilities of all pairwise intersections (to correct for double-counting). Then, it adds back the probabilities of all three-way intersections (because they were subtracted too many times), and so on, alternating signs until the intersection of all events is considered.

Case n=3: For three events : This can be visualized using a Venn diagram.

Example: Dice (n=3): Let’s calculate for the dice example using PIE. , , . , , . , . , . , . , .

This matches our previous calculation by listing the elements in .

Proof of the Principle of Inclusion-Exclusion (Beweis der Siebformel)

Consider an arbitrary elementary event . We need to show that is counted exactly once on both sides of the PIE formula.

  • Left-Hand Side (LHS): . By definition, is included exactly once in this sum because is in the union.

  • Right-Hand Side (RHS): Suppose belongs to exactly of the sets (where ). How many times is counted on the RHS?

    • It’s counted times in the first sum .
    • It’s counted times in the second sum (since is in an intersection if and only if it belongs to both and ).
    • It’s counted times in the sum corresponding to -way intersections .
    • It’s counted time in the -way intersection sum.
    • It’s counted times in sums for .

    The total number of times is counted on the RHS is:

    Recall the binomial theorem: . Let and . Then for : Therefore, .

Since is counted exactly once on both the LHS and RHS for any in the union, the Principle of Inclusion-Exclusion holds.

Laplace Space (Laplace-Raum)

A particularly important type of discrete probability space is the Laplace space.

Definition: A Laplace space is a finite probability space where all elementary events are equally likely.

If is the sample space of a Laplace space, then is finite, and for every :

Calculating Probabilities in a Laplace Space:

For any event in a Laplace space, the probability of is simply the ratio of the number of outcomes in to the total number of possible outcomes:

(Probability = Number of favorable outcomes / Total number of outcomes)

Example: Drawing a Card

Consider drawing a single card from a standard 52-card deck. Let be the set of all 52 cards. . The sample space is , and . Assuming the deck is well-shuffled, each card is equally likely to be drawn. This is a Laplace space. for any card .

Let be the event “drawing a King”. . . .

Composite Probability Spaces (zusammengesetzte W’räume)

Often, the most “natural” sample space for a problem might not be a Laplace space. It’s crucial to define the underlying probability space carefully, often by choosing a more detailed sample space that is a Laplace space, to correctly calculate probabilities.

Scenario 1: Drawing Two Cards

Experiment: Shuffle a deck and draw two cards.

  • Incorrect/Difficult ?: If we define , the set of all possible 2-card hands. . This is a Laplace space if we consider drawing the set of two cards. Each 2-card hand is equally likely. .
  • Alternative (Often Easier) : Define , the set of ordered pairs of distinct cards.
    • .
    • This is also a Laplace space. The first card can be any of the 52 (equally likely). Given , the second card can be any of the remaining 51 (equally likely).
    • .
    • Any specific 2-card hand corresponds to two outcomes in : and .
    • Therefore, , matching the probability calculated using .

Scenario 2: Rolling Two Dice and Summing

Experiment: Roll two fair dice and observe the sum of the numbers shown.

  • Incorrect : If we define (the possible sums). .
    • This is NOT a Laplace space. The outcome “sum = 2” can only happen in one way (1, 1), while “sum = 7” can happen in six ways (1,6), (2,5), (3,4), (4,3), (5,2), (6,1). Therefore, .
  • Correct : Define , the set of ordered pairs representing the outcomes of the two dice.
    • .
    • This is a Laplace space. Each pair is equally likely, with .
    • We can calculate probabilities of sums using :
      • Event “Sum = 2”: . . .
      • Event “Sum = 7”: . . .
      • Event “Sum = 10”: . . .

Key Takeaway: When calculating probabilities, especially involving multiple steps or components, it is often best to define the sample space such that it represents the most elementary, equally likely outcomes (a Laplace space), even if it’s more detailed than the final event you’re interested in.

Combinatorics Review: Counting the Ways to Choose

To correctly calculate probabilities, especially in Laplace spaces, we often need to count the number of possible outcomes () and the number of outcomes corresponding to a specific event (). Combinatorics provides the tools for this counting.

A fundamental problem in combinatorics is determining the number of ways to choose items from a set containing distinct items. The method for counting depends on two crucial questions:

  1. Does the order of selection matter? (Is the selection ordered or unordered?)
  2. Can items be selected more than once? (Is the selection with replacement or without replacement?)

Let’s explore the four resulting scenarios.

1. Ordered Selection with Replacement (Tuples)

  • Scenario: We select items from a set of distinct items. The order in which we select the items matters, and we are allowed to select the same item multiple times.
  • Intuition: Think of filling ordered slots. For the first slot, we have choices. Since we are replacing the item (or can choose the same type again), we still have choices for the second slot, choices for the third, and so on, up to the -th slot.
  • Derivation: This uses the basic multiplication principle of counting. We have independent choices to make, and each choice has possibilities. Total ways = (Choices for slot 1) (Choices for slot 2) (Choices for slot k) Total ways = ( times)
  • Formula: The number of ways is .
  • Result Type: An ordered list of length , often called a tuple.
  • Examples:
    • Possible 4-digit PIN codes using digits 0-9 (): .
    • Possible outcomes when rolling a die 3 times (): . (e.g., (1, 6, 1) is different from (6, 1, 1)).

2. Ordered Selection without Replacement (k-Permutations)

  • Scenario: We select items from a set of distinct items. The order of selection matters, but we cannot select the same item more than once. (Note: This requires ).
  • Intuition: Again, think of filling ordered slots. For the first slot, we have choices. Since we cannot replace the chosen item, we only have choices remaining for the second slot. For the third slot, we have choices, and so on, until the -th slot, for which we have choices.
  • Derivation: Using the multiplication principle with decreasing choices: Total ways = (Choices for slot 1) (Choices for slot 2) (Choices for slot k) Total ways =
  • Formula: This quantity is often denoted as (falling factorial) or . It can also be expressed using factorials: Recall that .
  • Result Type: An ordered list of distinct items, often called a k-permutation of .
  • Examples:
    • Ways to award Gold, Silver, Bronze medals in a race with 8 competitors (): .
    • Ways to arrange 3 distinct books from a collection of 5 on a shelf (): .

3. Unordered Selection without Replacement (Combinations / Sets)

  • Scenario: We select items from a set of distinct items. The order of selection does not matter, and we cannot select the same item more than once. (Requires ). This is equivalent to choosing a subset of size .
  • Intuition: How is this related to the ordered case without replacement (Case 2)? In Case 2, we counted sequences like (A, B, C) and (C, B, A) as distinct outcomes. However, if the order doesn’t matter, these sequences correspond to the same selection: the set . We need to figure out how many ordered sequences correspond to each unordered set.
  • Derivation:
    1. Start with the ordered count: From Case 2, we know there are ordered ways to select distinct items.
    2. Identify overcounting: Consider any specific set of items. How many different ways could we have ordered these items when we were counting in Case 2? There are ways to order distinct items (k choices for the first position, k-1 for the second, etc.).
    3. Correct for overcounting: Since each unordered set of size corresponds to exactly ordered sequences, the count from Case 2 () overcounts each unordered set by a factor of . To get the number of unordered sets, we divide the ordered count by the overcounting factor . Number of unordered sets =
  • Formula: This is the binomial coefficient, read as “n choose k”: Note that . Choosing items to include is the same as choosing items to exclude.
  • Result Type: An unordered set of distinct items, often called a combination.
  • Examples:
    • Ways to choose 3 winners from 10 lottery tickets (order doesn’t matter) (): .
    • Ways to form a 5-card poker hand from a 52-card deck (): .

4. Unordered Selection with Replacement (Multisets / Stars and Bars)

  • Scenario: We select items from a set of distinct types of items. The order of selection does not matter, and we can select the same type of item multiple times.
  • Intuition: This is often the trickiest case to grasp. Imagine we have bins, representing the distinct types of items we can choose from. We want to choose a total of items. Since order doesn’t matter and we can repeat types, this is like deciding how many times we choose type 1, how many times type 2, …, up to type , such that the total number of choices is .
  • Derivation (Stars and Bars technique):
    1. Represent Choices: Let “stars” represent the items we need to choose. Our goal is to divide these stars into groups, where each group corresponds to one of the types of items.
    2. Represent Dividers: To divide the stars into groups, we need “bars” (|). For example, if we have types and want to choose items, the sequence **|*||** could represent choosing 2 items of type 1, 1 item of type 2, 0 items of type 3, and 2 items of type 4.
    3. Combine Stars and Bars: Every possible selection corresponds uniquely to an arrangement of stars and bars in a sequence.
    4. Counting Arrangements: We have a total of positions in the sequence. We need to determine where the stars (or equivalently, the bars) go.
    5. Apply Combination Formula: This is now a combination problem (Case 3)! We need to choose positions for the stars out of the total positions. The number of ways to do this is . Alternatively, we could choose positions for the bars out of the total positions, which gives . These two binomial coefficients are equal.
  • Formula:
  • Result Type: An unordered collection where repetitions are allowed, often called a multiset.
  • Examples:
    • Ways to choose 3 scoops of ice cream from 5 available flavors (): .
    • Number of non-negative integer solutions to ( types/variables, total value/items): .

Summary Table

Selection TypeReplacement?Order Matters?Formula
TupleYesYes
k-PermutationNoYes
Combination / SetNoNo
Multiset / Stars and BarsYesNo

Examples

Example: Card Game - Dealing Hands

Scenario: Shuffle a 52-card deck (). Deal 5 cards to Player A and 5 cards to Player B.

Sample Space : An outcome is a pair of hands , where is Player A’s 5-card hand, is Player B’s 5-card hand, , , and the hands are disjoint ().

Calculating : This is a counting problem without replacement, and the order within a hand doesn’t matter, but the assignment to Player A vs Player B does. We can think sequentially:

  1. Choose 5 cards for Player A: There are ways.
  2. Choose 5 cards for Player B from the remaining 47 cards: There are ways.

Since these choices are made sequentially to define one outcome, we multiply the number of ways:

This represents the total number of ways to deal two distinct 5-card hands to two players. This forms a Laplace space, where each deal is equally likely.

(Note: The slide shows which is incorrect as it implies ordered selection with replacement. It also shows which is an alternative correct way: first choose 10 cards to be dealt, then assign 5 of those 10 to player A (the rest go to B).)

Example: Permutations and Derangements

Scenario: Shuffle a deck of cards (initially ordered 1 to ). What is the probability that at least one card ends up in its original position?

  • Sample Space : The set of all possible permutations of . . This is a Laplace space, assuming a perfect shuffle.

  • Event : “At least one card is in its original position.” (A fixed point exists).

  • Calculating using PIE: It’s easier to calculate by defining events for each card . Let be the event “Card is in position “. Then . We use the Principle of Inclusion-Exclusion:

    Consider the intersection of such events, . This is the event that cards are all in their original positions. The remaining cards can be permuted in ways. So, . .

    There are ways to choose the indices . The -th term in the PIE sum is:

    So, the PIE formula becomes:

    Recall the Taylor series expansion for . For , (for large ). Therefore, .

    The probability that at least one card remains in its original position converges to as becomes large. The probability that no card is in its original position (a derangement) converges to .

Continue here: 10 Conditional Probability, Independence, and Bayes’ Theorem