Olympiad in Informatics

Probability & Mathematical Expectation

Contents

  • Overview
  • Probability
    • Concepts Related to Probability
    • The Meaning of Probability
    • Probability of Simultaneous Occurrence
    • Axioms & Propositions of Probability
    • Conditional Probability
      • Concept
      • Law of Total Probability
      • Bayes' Formula
      • Examples
    • Random Variables
    • Applications of Probability in OI
  • Mathematical Expectation
    • The Concept of Mathematical Expectation
    • Linearity of Expectation & Recurrences
    • Applications of Mathematical Expectation in OI

Overview

Math takes up a large share of OI, mainly number theory, combinatorics, and probability and expectation. I recommend that readers learn permutations and combinations first before reading this article. In this article, I'm going to properly explain what probability and expectation are all about. I will explain it through mathematical concepts and OI problems. The concepts I learned all come from 《概率论基础教程》 — “A First Course in Probability”; readers interested in learning more can go take a look.

Probability

Concepts Related to Probability

Sample space: the set of all possible outcomes of an experiment is called the sample space of that experiment, usually written as \(S\).
Event: a subset of the sample space is called an event; if the outcome of a trial is contained in the event, we say the event occurred. It is usually written as \(E\) and can be understood as a set; for example, the event that at least one of two coins lands up can be written as \(E=\{ (Up,Down),(Up,Up),(Down,Up) \}\).
Mutually exclusive events: if there are two events \(E_1,E_2\) and \( E_1 \cap E_2 \), then events \(E_1,E_2\) are called mutually exclusive.
Complement transformation: within a set, if the answer set \(S_{ans}\) is hard to count, we can count its complement and use inclusion–exclusion to do a complement transformation: having found its complement \(S_{rev}\), the answer set is \(S_{ans}=S-S_{rev}\).
Probability: can be approximated as the proportion of all outcomes that a given event takes up in an experiment. So, \[P(E)=\lim_{n \to \infty} \frac{n(E)}{n} \] where \(n(E)\) is the number of times it occurs in \(n\) events. But theory and experiment always deviate somewhat, so to keep the math rigorous, probability is simply defined as this.

The Meaning of Probability

Probability is a very black magic sort of thing, so let's explain the formula above: \[P(E)=\lim_{n \to \infty} \frac{n(E)}{n} \]

In the formula above, \(P\) stands for some experiment, and \(P(E)\) stands for the probability of event \(E\) in the experiment, that is, the number of times event \(E\) occurs within a certain number of trials, divided by that number of trials. As the number of trials \(n\) tends to infinity, the probability becomes more and more accurate.

Probability of Simultaneous Occurrence

Now we have two events \(E,F\), and we write the probability that these two events occur at the same time as \(P(E \cap F)\), also written \(P(EF)\). Here, \(EF\) is defined as \( E \cap F \), i.e. the intersection of the two events.

Axioms & Propositions of Probability

Axiom 1
\[0 \leq P(E) \leq 1\]
Axiom 2
For an experiment \(P\), the probability of its sample space is: \[P(S)=1\]
Axiom 3
For a sequence of mutually exclusive events \(E_1,E_2,\dots\), that is, \(\forall i,j,E_i \cap E_j = \emptyset \), we have

\[ P(E_1 \cup E_2 \cup E_3 \cup \dots) = \sum_{i=1}^{\infty}P(E_i) \]

Here, a probability only counts as a probability if it satisfies the three axioms above.

Proposition 1
For \(P(E \cup F)\), we have the formula:
\[ P(E \cup F) = P(E) + P(F) - P(EF) \]
It can be proved with a Venn diagram.

Conditional Probability

Concept

As the name suggests, the concept of conditional probability is about the probability of an event occurring when a condition occurs. We write the probability of event \(E\) occurring given that event \(F\) occurs as \(P(E|F)\). Here, we have the formula

\[ P(E|F) = \frac {P(EF)}{P(F)} \]

My personal understanding: for event \(E\), given that event \(F\) occurs, the sample size shrinks from \(1\) to \(P(F)\), and the probability of both occurring at once is \(P(EF)\); naturally, under the condition (that \(F\) occurred), the probability becomes the ratio of the probability of occurring to the sample size.

Example 2a (Page 49 of the original book)

Joey is 80% certain that he put his missing key in one of the two pockets of his jacket. He is 40% sure he put it in the left pocket, and 40% sure he put it in the right pocket. If he checks the left pocket and does not find the key, what is the probability that the key is in the right pocket?

This is a classic conditional probability problem. Define \(R,L\) as the two events of putting the key in the left and right pockets; we can first write down the expression:

\[ P(R|L^c) = \frac{P(RL^c)}{P(L^c)} \]

Here the intersection of events \(RL^c\) evaluates to \(R\), which simplifies to:

\[ =\frac{P(R)}{1-P(L)} \]

The result is then obvious.

Law of Total Probability

Consider a partition of the sample space: \[ E_1, E_2, \dots, E_n, \forall E_i \cap E_j = \emptyset, \bigcup_i E_i = U \]

We can hand-wavily derive a formula:

\[ P(E) = \sum_i P(E|E_i)*P(E_i) \]

This is the famous law of total probability. We can understand the formula from this angle: the probability of an event occurring is actually equivalent to the probability of it occurring under any circumstances, which equals the union of it occurring under each circumstance; very easy to understand. Sometimes you can go at problems this way.

Bayes' Formula

Bayes' formula looks like this:

\[ P(A|B) = \frac{P(AB)}{P(B)} = \frac{P(B|A)P(A)}{P(B)} \]

This actually only takes a little shifting around of conditional probability to prove. \(P(AB) = P(B|A)P(A)\) can be understood as, given that \(A\) occurs, the probability of \(B\) occurring, in the probability of \(A\) occurring. The two are equivalent.