A Bernoulli distribution models one binary choice: 0 or 1. Read 0 as tails and 1 as heads, then assign each outcome its own weight. Equal weights produce a fair coin; unequal weights produce an unfair one. section 12.5 section 12.13
An integer-weight implementation makes the odds explicit and handles degenerate coins cleanly:
- Return a singleton distribution when either weight is zero: the result is always 0 or always 1. section 12.5
- Reduce positive weights by their greatest common divisor, then sample uniformly from their total and partition the range between 0 and 1. section 12.5
A coin with 5:7 odds
var coin = Bernoulli.Distribution(5, 7); int flip = coin.Sample(); The implementation reduces no further, samples uniformly from 0 through 11, and returns 0 for five positions and 1 for seven. Thus the coin produces 1 more often than 0 without exposing a direct Random call. section 12.5

