2.x β€” Chapter 2 summary and quiz

2.x β€” Chapter 2 summary and quiz#

Chapter summary#

In this chapter, we explored conditional probability, one of the most important concepts in probability theory and quantitative finance. Conditional probability allows us to update our beliefs about events when we receive new information.

Key concepts#

What we learned#

  1. Conditional Probability and Dependent Events (2.1):

    • Definition: (provided )
    • Multiplication rule:
    • Relationship to independence: if and only if and are independent
    • Chain rule for multiple events:
  2. Conditional Outcomes and Applications (2.2):

    • Conditional outcomes in complex scenarios
    • Probability trees for visualizing conditional scenarios
    • Law of Total Probability (introduction):
    • Conditional expectations:
    • Applications to risk assessment, portfolio management, and trading strategies

Applications in quantitative finance#

Important formulas#

ConceptFormula
Conditional Probability
Multiplication Rule
Chain Rule (2 events)
Chain Rule (n events)
Independence (conditional) if and only if independent
Law of Total Probability (for mutually exclusive, exhaustive )
Conditional Expectation

Next steps#

In Chapter 3, we’ll formally learn Bayes’ Theorem and the Law of Total Probability, which provide powerful tools for:

These concepts are fundamental for quantitative finance applications like risk modeling, signal processing, and decision-making under uncertainty.

Quiz time#

Question #1

A fair die is rolled. Let:

Calculate:

Show Solution

Sample space:

  • (even numbers)
  • (numbers > 3)
  • (even numbers > 3)

Since all outcomes are equally likely:

Using conditional probability formula:

Interpretation:

  • Given an even number, there’s a chance it’s greater than 3
  • Given a number greater than 3, there’s a chance it’s even

Question #2

Two cards are drawn from a standard deck without replacement. Calculate:

Show Solution
  • After drawing one ace, 3 aces remain out of 51 cards:

  • Using multiplication rule:

Question #3

A stock’s movement depends on market conditions:

Calculate:

Show Solution

Let:

  • = β€œBull market”:
  • = β€œBear market”:
  • = β€œStock goes up”

Part 1: Unconditional probability using Law of Total Probability:

Part 2: Reversing the conditional probability (using the formula we’ll learn as Bayes’ Theorem in Chapter 3):

Interpretation:

  • The unconditional probability of the stock going up is 56%
  • If the stock goes up, there’s an 85.7% chance we’re in a bull market

Question #4

A trading strategy has two signals:

Calculate:

Show Solution

Let:

  • = β€œSignal 1 correct”:
  • = β€œSignal 2 correct”: ,

Part 1: Both signals correct

Part 2: At least one signal correct

First, calculate using Law of Total Probability:

Now use addition rule:

Part 3: Reverse conditional probability

Interpretation:

  • Both signals are correct 56% of the time
  • At least one signal is correct 79% of the time
  • If Signal 2 is correct, Signal 1 is also correct 86.2% of the time

Question #5

A portfolio contains stocks from two sectors:

Calculate the unconditional expected return of the portfolio.

Show Solution

Let:

  • = β€œTechnology sector”:
  • = β€œFinance sector”:

Using Law of Total Expectation:

Interpretation: The unconditional expected return is 10.4%, which is a weighted average of the sector-specific expected returns.

Question #6

Three cards are drawn from a standard deck without replacement. Calculate the probability that all three are aces.

Show Solution

Using the chain rule:

Interpretation: The probability of drawing three aces in a row (without replacement) is approximately 0.018% (1 in 5,525).

Question #7

Write Python code to:

  1. Calculate conditional probability
  2. Calculate joint probability using multiplication rule
  3. Check if events are independent using conditional probability
  4. Calculate unconditional probability using Law of Total Probability
Show Solution
def conditional_probability(p_intersection, p_given):
    """Calculate P(B | A) = P(A ∩ B) / P(A)"""
    if p_given == 0:
        return None
    return p_intersection / p_given

def joint_probability(p_a, p_b_given_a):
    """Calculate P(A ∩ B) = P(A) * P(B | A)"""
    return p_a * p_b_given_a

def are_independent_conditional(p_a, p_b, p_b_given_a, tolerance=1e-6):
    """Check independence using conditional probability: P(B | A) = P(B)"""
    if p_a == 0:
        return None
    return abs(p_b_given_a - p_b) < tolerance

def law_of_total_probability(conditional_probs, prior_probs):
    """Calculate P(B) = sum of P(B | A_i) * P(A_i)"""
    if len(conditional_probs) != len(prior_probs):
        raise ValueError("Lists must have same length")
    return sum(c * p for c, p in zip(conditional_probs, prior_probs))

# Example 1: Conditional probability
p_intersection = 0.3
p_given = 0.6
p_conditional = conditional_probability(p_intersection, p_given)
print(f"P(B | A) = {p_conditional:.2f}")

# Example 2: Joint probability
p_a = 0.6
p_b_given_a = 0.5
p_joint = joint_probability(p_a, p_b_given_a)
print(f"P(A ∩ B) = {p_joint:.2f}")

# Example 3: Check independence
p_b = 0.5
is_independent = are_independent_conditional(p_a, p_b, p_b_given_a)
print(f"Are independent? {is_independent}")

# Example 4: Law of Total Probability
conditional_probs = [0.8, 0.2]  # P(up | bull), P(up | bear)
prior_probs = [0.6, 0.4]  # P(bull), P(bear)
p_unconditional = law_of_total_probability(conditional_probs, prior_probs)
print(f"P(up) = {p_unconditional:.2f}")

Output:

P(B | A) = 0.50
P(A ∩ B) = 0.30
Are independent? True
P(up) = 0.56