How a density changes under a transformation
The question
Can you turn a uniform input into the target density by changing the map?
- 1 SeeDrag the map to match a density.
- 2 TryTrace where an output band comes from.
- 3 ProveBuild the change-of-variables proof.
- 4 ApplyTry conversions, folds, and a sensor cap.
Before you start · 3 quick checks on area, undoing a map, and slope
Two ideas before you start
2 ideasProbability is the shaded area
A shaded interval under a constant density. Change its width with the buttons.
The rectangle's height stays fixed. The band with more area has more probability.
Exact definition
A variable \(X\) has a probability density \(f_X\) if \(f_X\) is nonnegative, has total integral one, and gives interval probabilities by area.
\[P(a\lt X\le b)=\int_a^b f_X(x)\,dx.\]Here \(a\le b\). The cumulative distribution function, or CDF, is \(F_X(x)=P(X\le x)\). It adds the area up to \(x\), so \(F_X'(x)=f_X(x)\) where the density is continuous. A single point under a density has probability zero. See PMF, PDF, and CDF for the difference between density and point mass.
A map moves both ends of a band
Two equal input steps on a curved map. The guides mark the input and output changes.
The two input steps have equal width. Switch bands to compare the output steps.
Exact definition
A transformation \(Y=g(X)\) applies a fixed function \(g\) to the input value. If \(g\) is strictly increasing or strictly decreasing on an interval, each output there has one input, \(x=g^{-1}(y)\). The symbol \(g^{-1}\) means the inverse function. It undoes \(g\).
For a differentiable map, the ratio of a small output width to its input width tends to \(\lvert g'(x)\rvert\) as an interval with endpoint \(x\) shrinks. Width uses absolute value because a decreasing map reverses the order of the ends.
Refresher on derivatives and scale
The chain rule says that if \(u=h(y)\) and \(A\) is differentiable at \(u\), the derivative of \(A(h(y))\) is \(A'(h(y))h'(y)\). If \(g\) and its inverse \(h\) are differentiable, use \(A=g\) and \(g(h(y))=y\). The product of the two derivatives at the matching points is one.
In one dimension the Jacobian of a differentiable map is its derivative, and its magnitude measures local length scaling. This lesson uses that one-dimensional scale. The proof uses this scale by differentiating the CDF.
Shape the map to match the target
- Drag the middle handle up or down, or focus it and use the arrow keys. The endpoints stay fixed, and the map rises on both sides.
- Watch the shaded input bands land at new positions. Compare the solid output outline with the dashed target.
- Press Check my map to score your attempt. Smaller error is better.
How the score measures error
At each output location, take the absolute difference between the two density heights. Integrate that gap across the output range, then divide by two. Both densities have area one, so the area where yours lies above the target equals the area where it lies below. Half the total gap is the excess area alone. Zero means the densities agree except possibly at individual points.
The input is uniform. The map is linear on either side of the handle, so both output outlines are made of rectangles. To measure their gap exactly, split the axis at both breakpoints and add the area of the gap on each piece. The displayed percentage is a share of probability mass.
Where does an output band come from?
Trace the input intervals
- Move the left end of the output band. Its width stays fixed.
- Read the matching parts of the input line. The table gives their probabilities.
- Use the graph and table to meet each goal.
| Input side | Interval | Probability |
|---|
When to add densities
The two sides of the absolute-value map are monotone branches. To find the probability of an output interval, add the probabilities of its disjoint input intervals. The same addition works for the density by taking the change in probability per unit width.
Suppose the input has a continuous density inside finitely many disjoint open intervals that together carry all its mass. If the map is continuously differentiable with nonzero derivative inside each interval, invert each branch separately. Away from the endpoints of the branch ranges, add \(f_X(h_j(y))\,|h_j'(y)|\) over the branches that reach \(y\). Here \(h_j\) is branch \(j\)'s inverse. Use the original \(f_X\) in each term so each contribution keeps its share of the total mass.
A flat stretch calls for a different calculation. If its input interval has positive probability, all that probability lands at a single output value. That gives a point mass.
Derive the density from the CDF
Let \(X\) have density \(f_X\) with all its mass in a bounded open interval \(I=(a,b)\). Assume \(f_X\) is continuous and strictly positive on \(I\) and zero outside \(I\). Let \(g\) be continuously differentiable on \(I\), strictly increasing or strictly decreasing there, with \(g'(x)\ne0\) for every \(x\in I\). Set \(Y=g(X)\), \(J=g(I)\), and let \(h=g^{-1}\) on \(J\).
For \(y\in J\), the output has density
\[\begin{aligned} f_Y(y)&= f_X(h(y))\,|h'(y)|\\ &=\frac{f_X(h(y))}{|g'(h(y))|}.\end{aligned}\]Use density zero outside \(J\). The endpoints, when finite, have no point mass. Their density values can be chosen without changing any probability.
Fix \(y\) inside \(J\). Choose the true statement in each line, using the stated direction of \(g\) in each case.
The range \(J\) is an open interval because \(g\) is continuous and strictly monotone on an open interval. The output lies in \(J\) with probability one. The CDF tends to zero at the lower end and one at the upper end, using limits if an end is infinite. On any closed subinterval of \(J\), integrating the continuous derivative gives the CDF difference. Taking limits to the ends of \(J\) gives total area one and accounts for every interval probability.
Problems
Decide first where the input can land. Give each answer as a fraction or a decimal. For density questions, use the units named in the prompt.
Further reading
- S. Ross, A First Course in Probability, 10th ed., chapter 5, “Continuous Random Variables.”