SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 5.1.1 Sample spaces, events and the axioms of probabilityConcept · 30 min
      2. 5.1.2 CountingConcept · 30 min
      3. 5.1.3 Conditional probability and independenceConcept · 30 min
      4. 5.1.4 Bayes' ruleConcept · 25 min
      5. 5.1.5 Practice set: probabilityPractice set · 25 min
      6. 5.1.6 Case study: default and rating-migration probabilitiesCase study · 35 min

Level 5, Probability and statistics 5.1 Probability basics Lesson 1 of 6

ConceptLesson 5.1.1 in Level 5, Probability and statistics. About 30 minutes.

Sample spaces, events and the axioms of probability

Experiments and sample spaces

An experiment is anything with an uncertain result: rolling a die, tossing a coin, drawing a card. Each possible result is an outcome. The set of all outcomes is the sample space, written Ω\Omega (the Greek capital omega).

  • One die: Ω={1,2,3,4,5,6}\Omega = \{1, 2, 3, 4, 5, 6\}, six outcomes.
  • A coin tossed twice: Ω={HH,HT,TH,TT}\Omega = \{HH, HT, TH, TT\}, with H for heads and T for tails. HTHT (heads, then tails) and THTH are different outcomes.
  • Two dice, one red and one blue: each outcome is a pair (a,b)(a, b), red first. There are 36 pairs.

Each time the experiment runs, exactly one outcome happens. So the sample space must list every possible result, and no two of its outcomes can happen together.

Rule: Sample space

Ω={all possible outcomes}\Omega = \{\text{all possible outcomes}\}

Each run of the experiment produces exactly one element of Ω\Omega. Keep different results apart: with two dice, (1,2)(1, 2) and (2,1)(2, 1) are two outcomes.

Try it

product(range(1, 7), repeat=2) lists every pair of faces, red first. A Python set of the pairs is Ω\Omega, as in lesson 0.2.1.

The last line counts the pairs and checks that (1,2)(1, 2) and (2,1)(2, 1) are both there.

⌘/Ctrl + Enter runs the cell

Events are sets of outcomes

An event is a set of outcomes: a subset of Ω\Omega, which means every element of it is in Ω\Omega. An event happens when the outcome of the run is one of its elements.

With one die, "the roll is even" is the event E={2,4,6}E = \{2, 4, 6\}. A roll of 4 makes EE happen; a roll of 3 does not.

Two events are special. Ω\Omega always happens: it is the certain event. The empty set ∅\varnothing has no elements and never happens: the impossible event.

A single outcome is an event too, such as {6}\{6\}.

With two dice, set-builder notation (lesson 0.2.1) describes events by a rule:

A={(a,b)∈Ω:a+b=7}B={(a,b)∈Ω:a=6 or b=6}\begin{gathered} A = \{(a, b) \in \Omega : a + b = 7\} \\ B = \{(a, b) \in \Omega : a = 6 \text{ or } b = 6\} \end{gathered}

AA, "the sum is 7", has 6 outcomes, from (1,6)(1, 6) to (6,1)(6, 1). BB, "at least one six", has 11. Six have the red die on 6 and six the blue die, but (6,6)(6, 6) counts once.

The 36 outcomes of two dice, each labelled with its sum. Event AA, a sum of 7, is the outlined diagonal of 6 cells; event BB, at least one six, is the 11 shaded cells. They share 2 cells.

And, or, not

The words that combine events become operations on sets.

Rule: Union, intersection, complement

A∪B: A or B or bothA∩B: A and BAc: not A\begin{gathered} A \cup B:\ A \text{ or } B \text{ or both} \\ A \cap B:\ A \text{ and } B \\ A^c:\ \text{not } A \end{gathered}

The union A∪BA \cup B holds every outcome in AA, in BB or in both. The intersection A∩BA \cap B holds the outcomes in both. The complement AcA^c holds every outcome of Ω\Omega that is not in AA.

With one die, take E={2,4,6}E = \{2, 4, 6\}, "even", and G={4,5,6}G = \{4, 5, 6\}, "at least 4".

  • E∪G={2,4,5,6}E \cup G = \{2, 4, 5, 6\}: even, or at least 4, or both.
  • E∩G={4,6}E \cap G = \{4, 6\}: even and at least 4.
  • Ec={1,3,5}E^c = \{1, 3, 5\}: odd.

In probability, "or" always includes "both". Two events with no outcome in common, A∩B=∅A \cap B = \varnothing, are disjoint, also called mutually exclusive: they cannot happen together. "Even" and "odd" are disjoint, and so is any event with its complement; together the two make up Ω\Omega.

On the grid, A∩B={(1,6),(6,1)}A \cap B = \{(1, 6), (6, 1)\}, and A∪BA \cup B has 6+11−2=156 + 11 - 2 = 15 outcomes: the overlap must not be counted twice.

Try it

Python's set operators match the symbols: | is ∪\cup, & is ∩\cap, and Omega - E is EcE^c.

E & {1, 3, 5} prints set(), the empty set: even and odd are disjoint. The last line counts AA, BB, A∩BA \cap B and A∪BA \cup B on the grid.

⌘/Ctrl + Enter runs the cell

The three axioms

A probability gives every event AA a number P(A)P(A), read "the probability of AA". It runs from 0 (the event never happens) to 1 (it always does) and has no units. It is often written as a percentage: P(A)=0.25P(A) = 0.25 is 25%.

One way to read it: run the experiment many times, and AA happens in a share of the runs close to P(A)P(A). The last section tests this with a simulation.

Any way of giving events numbers counts as a probability if it obeys three rules, the axioms. They are taken as the starting point, and every other rule follows from them.

Rule: The axioms of probability

1. P(A)≥02. P(Ω)=13. P(A∪B)=P(A)+P(B)if A∩B=∅\begin{gathered} 1.\ P(A) \ge 0 \\ 2.\ P(\Omega) = 1 \\ 3.\ P(A \cup B) = P(A) + P(B) \\ \text{if } A \cap B = \varnothing \end{gathered}

No probability is negative, some outcome is certain to happen, and the probabilities of disjoint events add. The third axiom also holds for a list of disjoint events A1,A2,…A_1, A_2, \ldots that never ends, which lesson 5.2.3 needs.

The outcomes need not be equally likely. A loaded die might show 6 half the time and each other face with probability 0.1. These six numbers are not negative and add up to 1, so they obey the axioms.

Single outcomes are disjoint, so axiom 3 adds them up for any event. For the loaded die, P(even)=P({2})+P({4})+P({6})=0.1+0.1+0.5=0.7P(\text{even}) = P(\{2\}) + P(\{4\}) + P(\{6\}) = 0.1 + 0.1 + 0.5 = 0.7.

Two rules that follow

Not. AA and AcA^c are disjoint and together make up Ω\Omega. So axioms 2 and 3 give P(A)+P(Ac)=1P(A) + P(A^c) = 1.

Rule: Complement rule

P(Ac)=1−P(A)P(A^c) = 1 - P(A)

The probability that AA does not happen. With A=ΩA = \Omega it gives P(∅)=0P(\varnothing) = 0. Use it when "not AA" is easier to count, as for "at least one".

With two fair dice, each of the 36 outcomes has probability 136\frac{1}{36}; a later section says why. "At least one six" is the complement of "no six", and no six leaves 5×5=255 \times 5 = 25 of the 36 outcomes. So P(B)=1−2536=1136P(B) = 1 - \frac{25}{36} = \frac{11}{36}.

Or. When AA and BB overlap, P(A)+P(B)P(A) + P(B) counts the outcomes of A∩BA \cap B twice. Subtract them once.

Rule: Addition rule

P(A∪B)=P(A)+P(B)−P(A∩B)P(A \cup B) = P(A) + P(B) - P(A \cap B)

For any two events. When they are disjoint, P(A∩B)=0P(A \cap B) = 0 and the rule is axiom 3.

On the grid, P(A∪B)=636+1136−236=1536=512P(A \cup B) = \frac{6}{36} + \frac{11}{36} - \frac{2}{36} = \frac{15}{36} = \frac{5}{12}. For the loaded die, P(even or at least 4)=0.7+0.7−0.6=0.8P(\text{even or at least } 4) = 0.7 + 0.7 - 0.6 = 0.8, since the overlap {4,6}\{4, 6\} has probability 0.6.

The axioms also fix the range. Since P(Ac)≥0P(A^c) \ge 0, no probability is above 1. And if every outcome of AA is in BB, then P(A)≤P(B)P(A) \le P(B).

The Proof Gym proves these rules from the axioms.

Try it

The loaded die is a dictionary from faces to probabilities. The cell checks that none is negative and that they add up to 1, then adds single outcomes to get each event.

round(…, 10) hides float noise such as 0.7999999999999999.

⌘/Ctrl + Enter runs the cell

Equally likely outcomes: probability by counting

Often every outcome is equally likely: a fair die, a fair coin, a well-shuffled deck. With nn outcomes, each then has probability 1n\frac{1}{n}, because the probabilities must add up to 1. So a probability becomes a count.

Rule: Equally likely outcomes

P(A)=∣A∣∣Ω∣P(A) = \frac{|A|}{|\Omega|}

∣A∣|A| is the number of outcomes in AA, and ∣Ω∣|\Omega| the number in the sample space. This works only when every outcome is equally likely.

Two fair dice have 36 equally likely outcomes. Counting the cells of the grid for each sum gives a table:

sum23456789101112
outcomes12345654321

So P(sum is 7)=636=16P(\text{sum is } 7) = \frac{6}{36} = \frac{1}{6}, the most likely sum, and P(sum is 2)=136P(\text{sum is } 2) = \frac{1}{36}. The algebra agrees: for each red value aa, exactly one blue value, 7−a7 - a, makes 7, so there are 6 outcomes. A sum of 2 needs both dice on 1.

The sums themselves are not equally likely. Treating the 11 sums as equally likely outcomes would give each 111\frac{1}{11}, which is wrong. The same trap hides in the number of heads in two tosses: one head comes from HTHT or THTH, so P(exactly one head)=24=12P(\text{exactly one head}) = \frac{2}{4} = \frac{1}{2}, not 13\frac{1}{3}.

Lesson 5.1.2 counts outcomes in sample spaces too large to list.

Try it

Counter counts the pairs that give each sum, which rebuilds the table. Fraction keeps the answers exact.

The last line counts the tosses with exactly one head. True counts as 1 in a sum.

⌘/Ctrl + Enter runs the cell

Simulation: probability as a long-run share

A computer can run an experiment many times, and the share of runs in which AA happens estimates P(A)P(A). NumPy's random numbers come from a generator, made by np.random.default_rng(seed). The same seed gives the same numbers every time, so anyone can repeat the run.

rng.integers(1, 7, size=(n, 2)) rolls two dice nn times: whole numbers from 1 to 6, stopping before 7 as range does. With the seed 1, the share of sums equal to 7 came out as:

rolls10010,0001,000,000
share with sum 70.190.16520.1665

The exact answer is 16≈0.1667\frac{1}{6} \approx 0.1667. After 100 rolls the share is off by more than 0.02; after a million it is within 0.0002. These numbers come from one seeded run: another seed gives slightly different shares.

The running share of sevens in one seeded run of a million rolls. It wanders at first, then settles on 16\frac{1}{6}.

Lesson 5.7.2 explains why the share settles, and how fast. For now a simulation is a check: if a million runs land far from your exact answer, one of the two is wrong.

Try it

The cell rolls two dice a million times with the seed 1. rolls.sum(axis=1) adds each pair, and (s[:n] == 7).mean() is the share of sevens among the first n rolls.

The next line checks two answers from above: at least one six, 1136≈0.3056\frac{11}{36} \approx 0.3056, and A∪BA \cup B, 1536≈0.4167\frac{15}{36} \approx 0.4167. The last lines roll the loaded die 100,000 times; its even share should be near 0.7.

⌘/Ctrl + Enter runs the cell

Case study 5.1.6 uses these rules on a table of credit ratings, where each row of probabilities must add up to 1.

Common mistakes

  1. "Or" includes "both". P(A∪B)=P(A)+P(B)P(A \cup B) = P(A) + P(B) only for disjoint events. Otherwise subtract P(A∩B)P(A \cap B), or the overlap counts twice.
  2. Counting needs equally likely outcomes. The 11 sums of two dice are not equally likely, and neither are 0, 1 and 2 heads. Count the equally likely pairs instead.
  3. Order counts in the sample space. With two dice, (1,2)(1, 2) and (2,1)(2, 1) are different outcomes, so a sum of 3 has probability 236\frac{2}{36}, not 136\frac{1}{36}.
  4. The complement of "at least one" is "none", not "exactly one". P(at least one six)=1−P(no six)P(\text{at least one six}) = 1 - P(\text{no six}).
  5. A probability lies between 0 and 1. An answer outside that range means a mistake, often an overlap counted twice. Six rolls of a die do not give a six with probability 6×16=16 \times \frac{1}{6} = 1; lesson 5.1.2 finds the true value.
  6. A simulated share is an estimate. It changes with the seed and the number of runs, so quote it rounded and beside the exact answer.

Sample spaces, events and axioms

0 of 13 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
  13. 13.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • An experiment's sample space Ω\Omega lists every outcome; exactly one happens per run. An event is a set of outcomes.
  • A∪BA \cup B is "AA or BB or both", A∩BA \cap B is "AA and BB", AcA^c is "not AA". Disjoint events have A∩B=∅A \cap B = \varnothing.
  • Axioms: P(A)≥0P(A) \ge 0, P(Ω)=1P(\Omega) = 1, and probabilities of disjoint events add.
  • P(Ac)=1−P(A)P(A^c) = 1 - P(A), and P(A∪B)=P(A)+P(B)−P(A∩B)P(A \cup B) = P(A) + P(B) - P(A \cap B).
  • With equally likely outcomes, P(A)=∣A∣∣Ω∣P(A) = \frac{|A|}{|\Omega|}. Sums of dice and numbers of heads are not equally likely.
  • A seeded simulation estimates P(A)P(A) by the share of runs in which AA happens; it settles on P(A)P(A) as the runs grow.
Next lesson5.1.2 Counting →

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.