teacher
Sign in

Probability and Expected Value

Compute averages over random processes with linearity of expectation, indicator variables and expected-value DP, and print fractions modulo a prime.

45 minCF 1500–22005 interactive10 problems

The problem

Randomness enters competitive programming in three ways.

  • Probability: how likely is an outcome? "What is the chance the die shows 6?"
  • Expected value (EV): the average result if you repeated the process many times. "On average, how many rolls until the first 6?"
  • Modular answers: the expected value is a fraction p/qp/q, and the statement asks for p⋅q−1p \cdot q^{-1} modulo a prime.

Definition: E[X]=∑xx⋅P(X=x)E[X] = \sum_x x \cdot P(X = x), each outcome weighted by its probability.

1 of 9