A probability distribution assigns probabilities to the possible outcomes of a random quantity. Its support is the set of those outcomes, and its probability mass function (PMF) gives each outcome’s probability. Discrete distributions use countable outcomes such as die values, coin sides, or marble colors; continuous distributions use ranges such as real numbers between 0 and 1. section 12.2
A discrete distribution becomes useful in a program when it provides:
- A finite support, such as {1, 2, 3, 4, 5, 6} for a die. section 12.2
- A PMF that may be uniform or weighted, such as red = 0.5, blue = 0.3, and green = 0.2. section 12.2
- A sampling operation that returns an outcome according to those probabilities, replacing direct manipulation of low-level random integers. section 12.2 section 12.3
An unfair coin
Model tails as 0 and heads as 1. A 30%-tails, 70%-heads coin uses weights 3 and 7, samples uniformly from 0 through 9, and maps 0–2 to tails and 3–9 to heads. The weights are reduced by their greatest common divisor, so the C# expression Bernoulli.Distribution(5, 7) describes five tails for every seven heads. section 12.5
var coin = Bernoulli.Distribution(5, 7);
int flip = coin.Sample();
A compact C# call shows the distribution abstraction in use: construct weighted odds once, then obtain outcomes with Sample(). section 12.5


























