LessonThis is a lesson restated in new words. Any figure in it is an example from the source, not this desk's record.

The inverse transform method builds samples from a target distribution out of uniform random numbers. Find the cumulative distribution function, invert it, draw a value between zero and one, and feed that draw through the inverse. For a fair die the result lands on each face about one sixth of the time. For an exponential law the inverse is a logarithm. The method needs an invertible distribution function, so it is not a universal generator.

Why it matters

A probability mass function assigns each outcome a probability. Under a frequency reading, repeating the experiment many times should recover those probabilities. You cannot get that structure by listing a few favorite outcomes. The cumulative distribution function, the CDF, adds the probabilities from the left until they reach one. Its range is always zero to one, for every distribution, because that is the scale probability lives on. A uniform draw also lives on zero to one. Inverting the CDF sends each uniform draw to the outcome that owns that slice of probability.

The idea in plain words

A fair die has sample space {1, 2, 3, 4, 5, 6}, each with probability 1/6, and probability zero elsewhere. The CDF stays at zero until 1, then jumps to 1/6, 2/6, 3/6, 4/6, 5/6, and finally 1 at 6, where it remains. A uniform number U is equally likely anywhere from zero to one. Place U on the vertical axis of the CDF and read across to the face that caused the jump. The lecture's example puts 0.5 on that graph. One sixth plus one sixth plus one sixth is 0.5, so the third jump is the one that covers 0.5, and the face is 3. A draw of 0.73 falls in a later step and maps to a later face. Doing this many times assigns each face its 1/6 share. After 10,000 simulated rolls in the lecture, the six frequencies sat near one sixth. Fresh runs differ, because the draws are random, but the shape of the mass function is what the map protects.

How to use it

Four steps cover the continuous case. Build the CDF. Invert it. Draw a standard uniform number. Return the inverse at that number. The discrete case adds a search. Compute the running sum of the masses, draw U, and return the smallest outcome whose running sum has reached U. A while-loop version starts the accumulated mass at zero and adds the next mass until U is covered. For a geometric law the support is unbounded, so you cannot store the whole CDF. The loop, fed by the mass function at each integer, is the version that still stops, because U is less than one and the accumulated mass eventually passes it. The uniform numbers themselves usually come from a pseudorandom generator. A linear congruential generator is the lecture's example: the next integer is a linear function of the current one, reduced modulo m, then divided by m so the output sits between zero and one. The constants are not arbitrary small integers. The literature uses large ones so the sequence looks uniform and has a long period. The sequence is deterministic. If the seed and the function are known, every later draw is fixed. That reproducibility is useful when you want to rerun a figure. It is a problem when someone can predict the draws.

What usually goes wrong

Inverting the density instead of the CDF breaks the map. The density does not run from zero to one in the way the CDF does, so a uniform input has nothing honest to land on. For a die, stopping at the wrong jump also mis-labels the face. The value 0.5 belongs to 3 because the third sixth completed the sum. Face 4 has not contributed yet.

A second failure is treating one unlucky sample as a broken generator. Ten heads in ten flips can happen. The check is the proportion over a large number of draws, which the law of large numbers pulls toward the true masses. A third failure is using the method on a normal draw and expecting a closed inverse. There isn't one in elementary functions. Switch methods rather than forcing an inverse that you cannot write.

Questions people ask

Why do I need a uniform draw to make any other draw?

Because every CDF runs from zero to one. A uniform number is a random height on that axis. Without it, the inverse has no random input. How the uniform numbers are manufactured is a separate topic. Library routines are enough if you only need the target sample.

What did 0.5 map to on the die?

Three. The CDF hits one half exactly when the third face has been included. The lecture uses that pair, 0.5 and 3, as the picture of the inverse.

Are the simulated die frequencies exactly one sixth?

Not in a finite run. The lecture's 10,000 rolls were approximately one sixth on each face. A new seed moves the counts. The method is working when those counts stay near the masses, not when one run matches them to the last digit.