A measurement error is equally likely to fall anywhere between and , and a quality score records the squared error . How likely is a squared error of at most ? Squaring sends and to the same output, so the answer has to collect probability from errors of both signs. This lesson finds the distribution of a function of a random variable by following events through the function, and then runs the same idea backward to turn uniform random numbers into draws from a chosen distribution, discrete or continuous.
Key terms
CDF method
Definition Let be a random variable with a known distribution, let be a function defined at every value can take, and let . The CDF method finds the CDF of at each real from
where is the set of all inputs whose output is at most , the preimage of . First find the set of values can take. Below all of them , and at or above all of them . For the remaining , solve the inequality for and compute from the distribution of . If the resulting is continuous everywhere and differentiable at all but finitely many points, then is a density of , with any values at the exceptional points.
In plain words Work with events rather than with density formulas. The output event ” is at most ” is the same event as ” lands among the inputs that produce such outputs”, so the two have the same probability. Once that input set is written down correctly, what remains is a probability calculation for .
Example A wait measured in minutes has , so its mean is half a minute. The same wait in seconds is . Every value of is nonnegative, so for . For ,
So , with rate per second and mean seconds, the same half minute. Changing units divides the rate by the conversion factor.
Monotone transformation
Definition Let take its values in an interval , let be continuous and strictly monotone on , and let . If is strictly increasing, then for every in the events and are equal, so
If is strictly decreasing, the inequality reverses. The event equals , so
which equals when is continuous. Each in the image is for exactly one in . For outside , is when lies below and when lies above it.
In plain words An increasing map keeps the order of values, so “output at most ” means “input at most the matching point”. A decreasing map turns the order around, so the same output event becomes an upper tail event for the input. Forgetting to flip the inequality is the usual mistake.
Example Let . The map is increasing, and for
The map is decreasing, and for
Both and are . They are still different random variables, since . The draw gives and . Two different maps can produce the same distribution.
Many-to-one transformation
Definition A function is many-to-one on the values of when some output is produced by two or more different inputs that can take. Then an output event can come from inputs on several branches of the inverse, and must include the probability of every input with , on every branch. For , when , and for
So for a continuous and ,
In plain words Before solving for , ask how many inputs give each output. Solving as alone throws away the negative inputs and the probability they carry.
Example Let and . The values of lie in . For the input interval from to has length out of a total length , so
In particular , which agrees with . Keeping only the branch would give , which is only at , although the event is certain.
Unbounded density
Definition A density is unbounded when it takes arbitrarily large values, that is, for every number there is a point with . This is allowed. A density only has to be nonnegative with total integral , so its graph may rise without bound near a point as long as the area under it stays finite. A random variable with an unbounded density is still continuous, so every single value has probability .
In plain words A tall density near a point means that short intervals near that point carry a lot of probability for their length. It does not put probability on the point itself. A density value is not a probability, so it may exceed .
Example For with , differentiating on gives
and outside . Near it grows without bound, for example , yet
The short interval and the much longer interval each have probability , since and . The single value has .
Inverse-CDF sampling
Definition Let , so for . Let be a CDF that is continuous and strictly increasing on an interval , where may be and may be , with as and as . Then maps one to one onto , and since lies in with probability , the random variable is defined with probability . It has CDF . For in the events and agree whenever lies in , so
and for or both sides are or both are . Generating this way is inverse-CDF sampling. The next card removes the conditions of continuity and strict increase. The reverse statement, that is when has CDF , holds whenever is continuous, but it fails for discrete distributions.
In plain words Read a uniform number as a probability level, and take as the sample the point where the CDF reaches that level. Where rises steeply, many levels land in a short stretch of values, so values there come up often.
Example For with rate , the CDF is for , so and . Solving for gives
so has the distribution . With and the draw is , the median of . The formula needs . Many software generators return numbers in , which keeps finite. The variant is also in theory, because is uniform too, but it fails if the generator returns exactly .
Generalized quantile
Definition For any CDF and any with , the generalized quantile is
The set is nonempty and bounded below, because tends to on the right and to on the left, and right-continuity of makes the infimum attained, so . For every real and every in ,
Hence has CDF when , with no continuity or strict increase required. When is continuous and strictly increasing where , the generalized quantile is the ordinary inverse of the previous card.
In plain words The generalized quantile at level is the first point where the CDF reaches . At a jump of the CDF a whole range of levels lands on the same value, and the length of that range is the probability of the value. Points inside a flat stretch of the CDF are never produced, which matches the zero probability there.
Example Let take the values , and with probabilities , and . Its CDF is on , on and from on, and the generalized quantile is constant on three ranges of levels.
| Level | |||
|---|---|---|---|
The levels , and give the draws , and . The three ranges of levels have lengths , and , exactly the masses. The level itself gives , since , and such single levels have probability anyway. The reverse statement fails for this , because takes only the values , and , so it is not uniform.
Check yourself
- Let and . Find the CDF of and its generalized quantile, and check that the quantile at level is .
Show the answer
The values of lie in , so for and for . Since , squaring is strictly increasing on the values of , and for
On this CDF is continuous and strictly increasing, so the quantile solves , which gives for . Then , and the check returns the level. This is the same CDF as that of for . A monotone map on and a two-branch map on give one distribution.
- Let and . Find for every real and the probability . What goes wrong if you keep only the branch ?
Show the answer
The values of lie in , and has density on . For both and lie in , so . For the negative branch is cut off at , so . Altogether for , for , and in between
Both formulas give at . Then . Keeping only the positive branch gives , which reaches only at . The missing is , the probability of the negative inputs.
- Let take the values , and with probabilities , and . Write its generalized quantile and the draws it gives at the levels , and . A classmate claims that is for every random variable with CDF . Test the claim on this .
Show the answer
The CDF is on , on and from on, so the generalized quantile is as follows.
| Level | |||
|---|---|---|---|
The level gives , the level gives because , and the level gives . The claim fails. The variable takes the values , and with probabilities , and , so , while a uniform variable would give . The claim is true when is continuous. Sampling with still works for this discrete , because it runs from to and rests only on the equivalence .