A probability distribution monad turns ordinary value workflows into workflows over random values. A discrete distribution generates T values according to a probability mass function; its unit wraps one value as a distribution. Chaining treats the first distribution as a prior and the next function as a likelihood, then combines their joint distribution and marginalizes the intermediate value. section 14.0 section 14.1
The monadic operations expose several useful interpretations:
- Map is ordinary projection over a distribution, while Join flattens a distribution whose outcomes are themselves distributions. section 14.1
- As an additive monad, distributions can merge supports, use an empty distribution as MZero, and filter values with Where. section 14.2
From a cold prior to a sneeze distribution
Start with a 90%/10% distribution for no cold versus cold. Bind it to a conditional sneeze distribution: without a cold, sneezing has weights 3/97; with a cold, 86/14. Marginalization produces weights of 113 for Yes and 887 for No, combining uncertainty about the cause with uncertainty about the symptom.
Flattening a choice of dice
A fair coin can choose between a six-sided die and a ten-sided die. The resulting nested distribution can be flattened with Join, yielding weights 8 for outcomes 1–6 and weights 3 for outcomes 7–10.
