✳ BETWEEN QUESTIONS ML STUDY ATLAS

A QUESTION-LED LESSON

Sampling from Distributions: How Does a Probability Become an Outcome?

A distribution assigns probabilities to outcomes. Sampling uses randomness to produce outcomes according to that distribution.

A discrete example

Suppose P(A) = 0.2, P(B) = 0.3 and P(C) = 0.5. The cumulative boundaries are 0.2, 0.5 and 1.0. For a uniform draw u in [0, 1), map u < 0.2 to A, 0.2 ≤ u < 0.5 to B, and the rest to C.

One outcome versus a frequency

Move the draw across the colored intervals. A occupies 20% of the line, B occupies 30%, and C occupies 50%. The line shows how a uniform number maps to one outcome. The slider chooses a number directly; it does not generate randomness. Slide the draw across 0.2 and 0.5. The selected outcome changes at the interval boundaries, whose widths correspond to the specified probabilities.

INTERACTIVE EXPLORATION

Map a draw to an outcome

Move a uniform draw u through [0, 1). The fixed probabilities are P(A) = 0.2, P(B) = 0.3 and P(C) = 0.5.

Sampling in models

Generative models use sampling in different ways, such as drawing a token from a predicted distribution or drawing a latent variable. A deterministic argmax choice is different from sampling.

Check your understanding

Which outcome corresponds to u = 0.35 in the example?

B: 0.2 ≤ 0.35 < 0.5.

Keep exploring

Probability and expectation ↗Language modeling ↗

Further reading

Source and further reading ↗