Trading Dev AcademyFree quant education

Free lesson · Math & notation

Probability, expectation and conditioning

Open interactive lessonPractice calculationsExplore labs

Start with the idea

An expectation weights each possible result by how often it occurs under the assumed model. Conditioning restricts the population before computing a frequency.

Symbols, units & horizon
  • X: random payoff
  • xⱼ: possible payoff j
  • pⱼ: probability of that payoff, nonnegative and summing to 1
  • E: expectation or probability-weighted average
  • P: probability
  • A, B: events
  • ∩: intersection, both events
  • |: given, restrict to event B
  • Σⱼ: sum over outcomes

When and why to use this

Use expected payoff to compare strategies and conditional probability to assess what a signal adds.

Probability P(A) measures the chance of event A under a model. It lies between 0 and 1. Expectation E[X] is a probability-weighted average of a random quantity X; it is not a promise for the next trade. The vertical bar in P(A|B) means “given B.”

𝔼[X]=∑jpjxj,P(A|B)=P(A∩B)P(B)
Algebra and arithmetic

Weight outcomes and restrict the denominator

  1. For outcomes xⱼ with probabilities pⱼ, sum pⱼxⱼ. A +10 payoff with probability .6 and −5 with probability .4 has expectation 6−2=4.
  2. If 12 of 20 signal days are wins, the conditional probability is 12/20=.6. Dividing counts by all observations in numerator and denominator gives the intersection formula.
Work it by hand

Expected payoff $4 does not mean the next trade earns $4; the example’s next payoff is either +$10 or −$5.

The intersection symbol ∩ means both events occur. A set lists possible outcomes; ∈ means “is a member of.” An indicator 1ₐ equals 1 when event A occurs and 0 otherwise. A hat, such as μ̂, marks an estimated rather than known parameter.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

from math import isclose

def expectation(outcomes, probabilities):
    if len(outcomes) != len(probabilities) or not probabilities:
        raise ValueError("Matching nonempty inputs required")
    if min(probabilities) < 0 or not isclose(sum(probabilities), 1):
        raise ValueError("Probabilities must be nonnegative and sum to one")
    return sum(x*p for x, p in zip(outcomes, probabilities))

def conditional(joint_probability, conditioning_probability):
    if not 0 <= joint_probability <= conditioning_probability <= 1 or conditioning_probability == 0:
        raise ValueError("Require 0 <= joint <= conditioning <= 1, conditioning > 0")
    return joint_probability / conditioning_probability

print(expectation([10, -5], [.6, .4]), conditional(.12, .20))

Continue learning

Math & Notation Essentials — all lessons
  1. Start with numbers, variables and an equals sign
  2. Percentages, basis points and units
  3. Rearrange an equation without changing its meaning
  4. Powers, square roots, exponentials and logarithms
  5. Read sums, indices, averages and squared deviations
  6. Probability, expectation and conditioning
  7. Vectors, matrices and transpose notation
  8. Derivatives, integrals and approximations

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations