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.
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 , and the statement asks for modulo a prime.
Definition: , each outcome weighted by its probability.
1 of 9