Transformations and joint distributions proofs — step by step with the food delivery order, the inverse of F, Cauchy–Schwarz and the Jacobian (and the density that came out negative)

In a practice exam in class I did a change of variables with two variables right until the last line, and on that line I wrote a negative density. The Jacobian came out as −t -t , I multiplied it in as it was and wrote down, very pleased with myself, that the joint density was −0.01 t e−0.1t -0.01\,t\,e^{-0.1t} , negative for every t>0 t > 0 . The lecturer didn’t write any comment in the margin: he just circled the minus sign and drew a question mark the size of the page. Two little bars were missing, those of the absolute value, and so was a glance at whether the result made sense.

This article is the extension of the transformations and joint distributions theory: there you have the results and how to use them; here, where they come from. These are the eight proofs that come up in the EC2 with this topic, each one with what we want to prove, where we start, each step with the property that justifies it, where people usually get stuck and how to check it with R. We keep the food delivery order: the kitchen X X and the delivery R R , independent and exp⁡(0.1) \exp(0.1) , and the arrival minute Y=X+R Y = X + R .

Table of Contents

Before we start: the rules we will use

RuleWhat it saysWhere it is used
Chain ruleddyF(h(y))=F′(h(y)) h′(y) \frac{d}{dy}F(h(y)) = F'(h(y))\,h'(y) Differentiating a composite distribution function
Derivative of the inverse(g−1)′(y)=1g′(x) (g^{-1})'(y) = \frac{1}{g'(x)} with x=g−1(y) x = g^{-1}(y) The sign of (g−1)′ (g^{-1})' is that of g′ g'
Continuous: points weigh nothingP(X=a)=0 P(X = a) = 0 , so P(X≥a)=1−F(a) P(X \ge a) = 1 – F(a) Going from ≥ \ge to 1−F 1 – F
Marginal∫f(x,y) dy=fX(x) \int f(x, y)\,dy = f_X(x) Going from a double integral to a single one
FubiniA double integral of a product g(x)h(y) g(x)h(y) over a rectangle is the product of integralsIndependence and expectations
mgfIt determines the distribution; that of a sum of independent variables is the productIdentifying the sum
LinearityE(aX+b)=aE(X)+b E(aX + b) = aE(X) + b In almost all of them

Proof 1: the change of variable theorem

What we want to prove

If X X is continuous with density fX f_X and Y=g(X) Y = g(X) , with g g differentiable and strictly monotonic on the support of X X , then

fY(y)=fX(g−1(y)) ∣ddyg−1(y)∣ f_Y(y) = f_X\big(g^{-1}(y)\big)\,\left|\frac{d}{dy}g^{-1}(y)\right|

Why it matters. It is the tool of the whole topic: every time you are asked for the density of a function of a variable (the rider’s time from their speed, the kitchen in seconds), this is the formula. And its idea, translating {Y≤y} \{Y \le y\} into an event about X X , comes back in proof 2.

Where we start

From the definition of distribution function, FY(y)=P(Y≤y) F_Y(y) = P(Y \le y) , and from the density being its derivative. The idea is to write the event {Y≤y} \{Y \le y\} as an event about X X , whose distribution we know. There are two cases, depending on whether g g goes up or down.

The event Y ≤ y, seen on the X axisTwo graphs of y equals g of x with a horizontal line at a value y. On the left, g increasing: the x values with g of x at most y are those left of g inverse of y, marked in green. On the right, g decreasing: they are those right of g inverse of y. The inequality flips.05100510xy = g(x)yg⁻¹(y)g increasing: X ≤ g⁻¹(y)05100510xy = g(x)yg⁻¹(y)g decreasing: X ≥ g⁻¹(y)
In green, the values of X that make Y ≤ y: on one side or the other depending on whether g rises or falls.

Case 1: g increasing

If g g is increasing, applying g−1 g^{-1} (also increasing) to both sides keeps the inequality:

FY(y)=P(g(X)≤y)=P(X≤g−1(y))=FX(g−1(y)) F_Y(y) = P(g(X) \le y) = P\big(X \le g^{-1}(y)\big) = F_X\big(g^{-1}(y)\big)

Differentiating with the chain rule:

fY(y)=fX(g−1(y))⋅ddyg−1(y) f_Y(y) = f_X\big(g^{-1}(y)\big)\cdot\frac{d}{dy}g^{-1}(y)

And since g−1 g^{-1} is increasing, its derivative is positive: it equals its absolute value.

Where that derivative comes from: the outer function is FX F_X , whose derivative is fX f_X , and the inner one is g−1 g^{-1} . It is the chain rule from the table with F=FX F = F_X and h=g−1 h = g^{-1} . In case 2 you differentiate the same way, with the minus sign of 1−FX 1 – F_X in front.

Case 2: g decreasing

If g g is decreasing, applying g−1 g^{-1} flips the inequality (that is what you see in the drawing, on the right):

FY(y)=P(g(X)≤y)=P(X≥g−1(y))=1−FX(g−1(y)) F_Y(y) = P(g(X) \le y) = P\big(X \ge g^{-1}(y)\big) = 1 – F_X\big(g^{-1}(y)\big)

The last step uses that X X is continuous: P(X≥a)=1−P(X<a)=1−FX(a) P(X \ge a) = 1 – P(X < a) = 1 – F_X(a) , because the point a a weighs nothing. Differentiating:

fY(y)=−fX(g−1(y))⋅ddyg−1(y) f_Y(y) = -f_X\big(g^{-1}(y)\big)\cdot\frac{d}{dy}g^{-1}(y)

Now g−1 g^{-1} is decreasing and its derivative is negative, so −ddyg−1(y)=∣ddyg−1(y)∣ -\frac{d}{dy}g^{-1}(y) = \left|\frac{d}{dy}g^{-1}(y)\right| .

Putting the two cases together

In both you get fX(g−1(y)) f_X(g^{-1}(y)) times a positive factor which is the absolute value of the derivative of the inverse. That is the theorem. The support of Y Y is the image under g g of the support of X X .

Where people get stuck is case 2: either they don’t flip the inequality, or they flip it and then put the absolute value on again, counting the sign twice. If you do the case with F F step by step, the sign comes out on its own.

Check it with R

The rider from the theory: V∼U(12,20) V \sim U(12, 20) and R=180/V R = 180/V , decreasing. The theorem gives fR(r)=22.5/r2 f_R(r) = 22.5/r^2 on (9,15) (9, 15) . We compare a probability computed both ways: integrating the new density and translating the event to the speed.

fR <- function(r) 22.5 / r^2
integrate(fR, 9, 11)$value          # P(R <= 11) with the theorem's density
1 - punif(180 / 11, 12, 20)         # P(V >= 180/11): the same event

Output:

[1] 0.4545455
[1] 0.4545455

Both give the same, 0.45 (exactly 5/11 5/11 ). In the second line you see case 2 at work: R≤11  ⟺  V≥180/11 R \le 11 \iff V \ge 180/11 , with the inequality flipped.

Check you’ve got it: where does fR(r)=22.5/r2 f_R(r) = 22.5/r^2 for the rider come from, and why on (9,15) (9, 15) ?

The inverse of r=180/v r = 180/v is v=180/r v = 180/r , with derivative −180/r2 -180/r^2 : negative, because g g is decreasing (case 2), and the absolute value turns it into 180/r2 180/r^2 . Since fV=1/8 f_V = 1/8 on (12,20) (12, 20) , fR(r)=18⋅180r2=22.5r2 f_R(r) = \frac{1}{8}\cdot\frac{180}{r^2} = \frac{22.5}{r^2} . The support is the image of V V ‘s: 180/20=9 180/20 = 9 and 180/12=15 180/12 = 15 , with the endpoints swapped because g g goes down.

Proof 2: the square of a standard normal is a chi-squared

What we want to prove

If Z∼N(0,1) Z \sim N(0, 1) , then W=Z2 W = Z^2 has density

fW(w)=12πw e−w/2,w>0 f_W(w) = \frac{1}{\sqrt{2\pi w}}\,e^{-w/2}, \qquad w > 0

which is the χ2(1) \chi^2(1) , that is, a gamma(1/2, 1/2) \text{gamma}(1/2,\ 1/2) .

Why it matters. It shows what to do when g g is not monotonic and proof 1 does not apply: go back to F F and look at how many values of Z Z lead to each w w . And the χ2 \chi^2 comes back in the sampling distributions topic, with the sample variance.

Where we start

g(z)=z2 g(z) = z^2 is not monotonic on the line (it goes down to 0 and then up), so the theorem in proof 1 doesn’t apply. We go back to the distribution function.

Z² ≤ w is the central interval of the bellOn the left, the parabola w equals z squared and a horizontal line at w equals 1.5, which cuts it at minus root w and root w, about 1.22; in green, the interval between both cuts. On the right, the standard normal bell with the central area between minus 1.22 and 1.22 shaded in green: it is the distribution function of W at 1.5, 0.7793.0246−2−1012zw = z²w = 1.5−√w√w0.00.10.20.30.4−3−2−10123zφ(z)F_W(1.5)= 0.7793two branches,same weight
Each w comes from two values of z, one on each side: that is why there are two terms when differentiating.

Step 1: the support

Z2≥0 Z^2 \ge 0 always, so for w≤0 w \le 0 , FW(w)=0 F_W(w) = 0 . We work with w>0 w > 0 .

Step 2: the event, in terms of Z

Z2≤w Z^2 \le w is the same as ∣Z∣≤w |Z| \le \sqrt{w} , that is, −w≤Z≤w -\sqrt{w} \le Z \le \sqrt{w} . It is the central interval in the drawing:

FW(w)=P(−w≤Z≤w)=Φ(w)−Φ(−w) F_W(w) = P(-\sqrt{w} \le Z \le \sqrt{w}) = \Phi(\sqrt{w}) – \Phi(-\sqrt{w})

Step 3: differentiate

With the chain rule on each term, and knowing that ddww=12w \frac{d}{dw}\sqrt{w} = \frac{1}{2\sqrt{w}} and ddw(−w)=−12w \frac{d}{dw}(-\sqrt{w}) = -\frac{1}{2\sqrt{w}} :

fW(w)=φ(w)⋅12w−φ(−w)⋅(−12w)=12w(φ(w)+φ(−w)) f_W(w) = \varphi(\sqrt{w})\cdot\frac{1}{2\sqrt{w}} – \varphi(-\sqrt{w})\cdot\left(-\frac{1}{2\sqrt{w}}\right) = \frac{1}{2\sqrt{w}}\big(\varphi(\sqrt{w}) + \varphi(-\sqrt{w})\big)

Why the minus turns into a plus: the derivative of Φ \Phi is φ \varphi , and in the second term, −Φ(−w) -\Phi(-\sqrt{w}) , the inner derivative is −12w -\frac{1}{2\sqrt{w}} . Minus times minus is plus: the two branches add up.

Step 4: use the symmetry and substitute

The normal density is even, φ(−a)=φ(a) \varphi(-a) = \varphi(a) , so the bracket is 2φ(w) 2\varphi(\sqrt{w}) :

fW(w)=1w φ(w)=1w⋅12π e−(w)2/2=12πw e−w/2 f_W(w) = \frac{1}{\sqrt{w}}\,\varphi(\sqrt{w}) = \frac{1}{\sqrt{w}}\cdot\frac{1}{\sqrt{2\pi}}\,e^{-(\sqrt{w})^2/2} = \frac{1}{\sqrt{2\pi w}}\,e^{-w/2}

Step 5: recognise it

A gamma(α,β) \text{gamma}(\alpha, \beta) has density βαΓ(α)wα−1e−βw \frac{\beta^\alpha}{\Gamma(\alpha)}w^{\alpha – 1}e^{-\beta w} . With α=β=1/2 \alpha = \beta = 1/2 and Γ(1/2)=π \Gamma(1/2) = \sqrt{\pi} :

(1/2)1/2π w−1/2 e−w/2=12π w−1/2 e−w/2 \frac{(1/2)^{1/2}}{\sqrt{\pi}}\,w^{-1/2}\,e^{-w/2} = \frac{1}{\sqrt{2\pi}}\,w^{-1/2}\,e^{-w/2}

The same. The gamma(1/2, 1/2) \text{gamma}(1/2,\ 1/2) is called χ2(1) \chi^2(1) .

Using only the positive root, z=w z = \sqrt{w} , and writing fW(w)=φ(w)⋅12w f_W(w) = \varphi(\sqrt{w})\cdot\frac{1}{2\sqrt{w}} . It is half the density: it integrates to 0.5. Each value of w w comes from two values of z z .

Check it with R

fW <- function(w) exp(-w / 2) / sqrt(2 * pi * w)
integrate(fW, 0, Inf)                          # a density: integrates to 1
c(fW(1.5), dchisq(1.5, df = 1), dgamma(1.5, 0.5, 0.5))

Output:

1 with absolute error < 6.4e-05
[1] 0.1538663 0.1538663 0.1538663

It integrates to 1 and, at w=1.5 w = 1.5 , the three versions (ours, dchisq and dgamma) give the same height, 0.1539.

Check you’ve got it: without integrating anything, what is P(W≤1) P(W \le 1) ?

0.68. By step 2, W≤1 W \le 1 is the same as −1≤Z≤1 -1 \le Z \le 1 , so P(W≤1)=Φ(1)−Φ(−1)=0.84−0.16=0.68 P(W \le 1) = \Phi(1) – \Phi(-1) = 0.84 – 0.16 = 0.68 : landing less than one standard deviation from the mean. In R, pchisq(1, 1) gives the same.

Proof 3: the inverse of F (simulating any distribution)

What we want to prove

Let X X be continuous with distribution function F F , strictly increasing on its support (so F−1 F^{-1} exists). Then:

  1. Z=F(X)∼U(0,1) Z = F(X) \sim U(0, 1) .
  2. If U∼U(0,1) U \sim U(0, 1) , the variable F−1(U) F^{-1}(U) has distribution function F F .

Why it matters. Part 2 is the recipe for simulating any continuous distribution with nothing but uniform numbers: if you can solve u=F(x) u = F(x) for x x , you can simulate X X . It is what you will use when a distribution does not come ready-made in R.

Where we start

From two things: F F takes values between 0 and 1, and since it is increasing, a≤b  ⟺  F(a)≤F(b) a \le b \iff F(a) \le F(b) (and the same with F−1 F^{-1} ). For the uniform, P(U≤u)=u P(U \le u) = u if 0<u<1 0 < u < 1 .

Simulating with the inverse: from a random height to a kitchen timeThe distribution function of the exponential with rate 0.1 between 0 and 50 minutes. Three arrows leave the vertical axis at heights 0.2, 0.5 and 0.8, reach the curve and go down to the horizontal axis at 2.23, 6.93 and 16.09 minutes.0.00.20.40.60.81.001020304050kitchen x (min)u = F(x)u = 0.22.23u = 0.56.93u = 0.816.09x = −10·log(1 − u)
Evenly spread heights give times piled up where F rises fast: the short times.

Part 1: F(X) is uniform

Z=F(X) Z = F(X) lives between 0 and 1. For 0<z<1 0 < z < 1 , we apply F−1 F^{-1} to both sides (increasing: the inequality is kept):

P(Z≤z)=P(F(X)≤z)=P(X≤F−1(z))=F(F−1(z))=z P(Z \le z) = P\big(F(X) \le z\big) = P\big(X \le F^{-1}(z)\big) = F\big(F^{-1}(z)\big) = z

P(Z≤z)=z P(Z \le z) = z on (0,1) (0, 1) is the distribution function of the U(0,1) U(0, 1) .

The step that gets skipped: F(F−1(z))=z F\big(F^{-1}(z)\big) = z because F−1(z) F^{-1}(z) is exactly the x x at which F F equals z z . And 0<z<1 0 < z < 1 is required because that is the only place where F−1 F^{-1} is defined.

Part 2: F⁻¹(U) has distribution F

Now we apply F F to both sides:

P(F−1(U)≤x)=P(U≤F(x))=F(x) P\big(F^{-1}(U) \le x\big) = P\big(U \le F(x)\big) = F(x)

The last equality is the uniform’s, because F(x) F(x) is a number between 0 and 1.

For the kitchen

With F(x)=1−e−0.1x F(x) = 1 – e^{-0.1x} , solving u=1−e−0.1x u = 1 – e^{-0.1x} : e−0.1x=1−u e^{-0.1x} = 1 – u , x=−10log⁡(1−u) x = -10\log(1 – u) . So −10log⁡(1−U)∼exp⁡(0.1) -10\log(1 – U) \sim \exp(0.1) . And since 1−U 1 – U is also U(0,1) U(0, 1) , −10log⁡(U) -10\log(U) works just as well.

In the drawing, simulating with the inverse is “shooting a horizontal arrow” from a random height u u to the curve of F F and dropping down to the axis: the areas where F F rises fast (where the density is high) receive more arrows.

Check it with R

set.seed(2026)
x <- -10 * log(runif(1e5))                      # the inverse with U instead of 1 - U
round(quantile(x, c(0.25, 0.5, 0.75)), 2)       # simulated quartiles
round(qexp(c(0.25, 0.5, 0.75), 0.1), 2)         # quartiles of the exp(0.1)
round(mean(pexp(x, 0.1) <= 0.3), 3)             # part 1: F(X) is uniform

Output:

  25%   50%   75% 
 2.86  6.89 13.86 
[1]  2.88  6.93 13.86
[1] 0.302

The simulated quartiles are a few hundredths from the theoretical ones, and the proportion of F(X)≤0.3 F(X) \le 0.3 comes out 0.302: practically the 0.3 a uniform gives.

Check you’ve got it: if runif gives u=0.5 u = 0.5 , what kitchen time does −10log⁡(1−u) -10\log(1 – u) simulate? And −10log⁡(u) -10\log(u) ?

Both, 6.93 minutes: with u=0.5 u = 0.5 , also 1−u=0.5 1 – u = 0.5 , and −10log⁡(0.5)=10log⁡2=6.93 -10\log(0.5) = 10\log 2 = 6.93 . It is the median of the kitchen, the 50% in the R output.

Proof 4: the expectation of a sum and of a product

What we want to prove

For X X and Y Y with joint density f(x,y) f(x, y) :

  1. E(aX+bY)=aE(X)+bE(Y) E(aX + bY) = aE(X) + bE(Y) , always.
  2. If they are independent, E(g(X)h(Y))=E(g(X)) E(h(Y)) E\big(g(X)h(Y)\big) = E\big(g(X)\big)\,E\big(h(Y)\big) . In particular, E(XY)=E(X)E(Y) E(XY) = E(X)E(Y) .

Why it matters. With part 1, the mean of the arrival, E(Y)=E(X)+E(R)=20 E(Y) = E(X) + E(R) = 20 , comes out without touching the joint density. Part 2 is the piece used in proofs 5 and 7: the covariance of two independent variables is 0, and the mgf of a sum splits into a product.

Where we start

From the definition E(g(X,Y))=∫ ⁣ ⁣∫g(x,y)f(x,y) dx dy E(g(X, Y)) = \int\!\!\int g(x, y)f(x, y)\,dx\,dy and from the marginal. We do the continuous case; the discrete one is the same with sums.

Part 1: the sum

E(aX+bY)=∫ ⁣ ⁣∫(ax+by) f(x,y) dx dy=a∫ ⁣ ⁣∫x f(x,y) dy dx+b∫ ⁣ ⁣∫y f(x,y) dx dy E(aX + bY) = \int\!\!\int (ax + by)\,f(x, y)\,dx\,dy = a\int\!\!\int x\,f(x, y)\,dy\,dx + b\int\!\!\int y\,f(x, y)\,dx\,dy

In the first term, x x doesn’t depend on y y and comes out of the inner integral, which is the marginal:

∫x(∫f(x,y) dy)dx=∫x fX(x) dx=E(X) \int x\left(\int f(x, y)\,dy\right)dx = \int x\,f_X(x)\,dx = E(X)

The same in the second with fY f_Y . We are left with aE(X)+bE(Y) aE(X) + bE(Y) . We haven’t used independence at any point.

What the first line does without saying so: the integral of a sum is the sum of the integrals, and constants come out. Then you integrate first in the variable that does not appear, and that leaves the marginal on its own.

Part 2: the product, with independence

If they are independent, f(x,y)=fX(x) fY(y) f(x, y) = f_X(x)\,f_Y(y) , and the double integral of a product of a function of x x and another of y y splits:

E(g(X)h(Y))=∫ ⁣ ⁣∫g(x)h(y) fX(x)fY(y) dx dy=(∫g(x)fX(x) dx)(∫h(y)fY(y) dy)=E(g(X)) E(h(Y)) E\big(g(X)h(Y)\big) = \int\!\!\int g(x)h(y)\,f_X(x)f_Y(y)\,dx\,dy = \left(\int g(x)f_X(x)\,dx\right)\left(\int h(y)f_Y(y)\,dy\right) = E(g(X))\,E(h(Y))

The independence hypothesis is used in the first step, when writing f=fXfY f = f_X f_Y . Without it, the integral doesn’t split.

The converse is not true

With Q∼N(0,4) Q \sim N(0, 4) , E(Q⋅Q2)=E(Q3)=0=E(Q) E(Q2) E(Q\cdot Q^2) = E(Q^3) = 0 = E(Q)\,E(Q^2) , and Q Q and Q2 Q^2 are not independent. The product coming out “as if they were” proves nothing.

Check it with R

In the order, X X and Y Y are not independent: E(XY) E(XY) need not be E(X)E(Y)=200 E(X)E(Y) = 200 . We integrate it over the triangle:

g <- function(x) integrate(function(y) x * y * 0.01 * exp(-0.1 * y), x, Inf)$value
integrate(Vectorize(g), 0, Inf)$value        # E(XY) on 0 < x < y
10 * 20                                       # E(X) E(Y)

Output:

[1] 300
[1] 200

300 against 200: the difference, 100, is exactly the covariance from the theory.

Check you’ve got it: in the order, why is E(X+Y)=30 E(X + Y) = 30 correct even though X X and Y Y are not independent, while E(XY)=200 E(XY) = 200 is not?

Part 1 does not use independence: E(X+Y)=10+20=30 E(X + Y) = 10 + 20 = 30 always. Part 2 does, when writing f=fXfY f = f_X f_Y . Since the arrival includes the kitchen, the joint density does not split and E(XY) E(XY) comes out as 300. A sum always splits; a product, only with independence.

Proof 5: the variance of a linear combination and the covariance with constants

What we want to prove

  1. Var(aX+bY)=a2Var(X)+b2Var(Y)+2ab Cov(X,Y) \mathrm{Var}(aX + bY) = a^2\mathrm{Var}(X) + b^2\mathrm{Var}(Y) + 2ab\,\mathrm{Cov}(X, Y) .
  2. Cov(aX+b, cY+d)=ac Cov(X,Y) \mathrm{Cov}(aX + b,\ cY + d) = ac\,\mathrm{Cov}(X, Y) .
  3. ρaX+b, cY+d=ρXY \rho_{aX + b,\ cY + d} = \rho_{XY} if ac>0 ac > 0 and −ρXY -\rho_{XY} if ac<0 ac < 0 .

Why it matters. The first formula gives the variance of any sum, also of dependent variables like the kitchen and the arrival: the 2ab Cov(X,Y) 2ab\,\mathrm{Cov}(X, Y) is what gets forgotten. The other two explain why the covariance changes with the units and the correlation does not.

Where we start

From the definitions Var(W)=E(W−E(W))2 \mathrm{Var}(W) = E(W – E(W))^2 and Cov(X,Y)=E[(X−μX)(Y−μY)] \mathrm{Cov}(X, Y) = E\big[(X – \mu_X)(Y – \mu_Y)\big] , and from the linearity in proof 4.

Part 1: the variance

By linearity, E(aX+bY)=aμX+bμY E(aX + bY) = a\mu_X + b\mu_Y . We subtract and group:

aX+bY−(aμX+bμY)=a(X−μX)+b(Y−μY) aX + bY – (a\mu_X + b\mu_Y) = a(X – \mu_X) + b(Y – \mu_Y)

We square it ((A+B)2=A2+B2+2AB (A + B)^2 = A^2 + B^2 + 2AB ) and take expectations, again by linearity:

Var(aX+bY)=a2E(X−μX)2+b2E(Y−μY)2+2ab E[(X−μX)(Y−μY)] \mathrm{Var}(aX + bY) = a^2E(X – \mu_X)^2 + b^2E(Y – \mu_Y)^2 + 2ab\,E\big[(X – \mu_X)(Y – \mu_Y)\big]

and each expectation is, by definition, Var(X) \mathrm{Var}(X) , Var(Y) \mathrm{Var}(Y) and Cov(X,Y) \mathrm{Cov}(X, Y) . With independence, the covariance is 0 (proof 4) and you get the topic 5 formula.

Where the squares come from: (a(X−μX))2=a2(X−μX)2 \big(a(X – \mu_X)\big)^2 = a^2(X – \mu_X)^2 , and the cross term is 2ab(X−μX)(Y−μY) 2ab(X – \mu_X)(Y – \mu_Y) . When taking expectations, a2 a^2 , b2 b^2 and 2ab 2ab come out because they are constants.

Part 2: the covariance with constants

E(aX+b)=aμX+b E(aX + b) = a\mu_X + b , so (aX+b)−E(aX+b)=a(X−μX) (aX + b) – E(aX + b) = a(X – \mu_X) : the constant b b disappears. The same with cY+d cY + d . Then

Cov(aX+b, cY+d)=E[a(X−μX)⋅c(Y−μY)]=ac Cov(X,Y) \mathrm{Cov}(aX + b,\ cY + d) = E\big[a(X – \mu_X)\cdot c(Y – \mu_Y)\big] = ac\,\mathrm{Cov}(X, Y)

Part 3: the correlation

With Var(aX+b)=a2Var(X) \mathrm{Var}(aX + b) = a^2\mathrm{Var}(X) , the standard deviations are ∣a∣σX |a|\sigma_X and ∣c∣σY |c|\sigma_Y :

ρaX+b, cY+d=ac Cov(X,Y)∣a∣σX⋅∣c∣σY=ac∣ac∣ ρXY \rho_{aX + b,\ cY + d} = \frac{ac\,\mathrm{Cov}(X, Y)}{|a|\sigma_X\cdot|c|\sigma_Y} = \frac{ac}{|ac|}\,\rho_{XY}

ac∣ac∣ \frac{ac}{|ac|} is 1 if ac>0 ac > 0 and −1 -1 if ac<0 ac < 0 . That is why the correlation between the kitchen and the arrival is the same in minutes as in seconds: it has no units.

Check it with R

set.seed(2026)
x <- rexp(1e5, 0.1); y <- x + rexp(1e5, 0.1)
round(c(cor(x, y), cor(60 * x + 5, y), cor(x, -2 * y + 7)), 4)
round(c(var(2 * x - 3 * y),
        4 * var(x) + 9 * var(y) - 12 * cov(x, y)), 2)

Output:

[1]  0.7055  0.7055 -0.7055
[1] 1007.29 1007.29

The correlation doesn’t change when the kitchen goes to seconds and gets 5 added, and only changes sign when the arrival is multiplied by −2 -2 . In the second line, the formula gives exactly the simulated variance (it is an algebraic identity, also with data). In theory, 4⋅100+9⋅200−12⋅100=1000 4\cdot 100 + 9\cdot 200 – 12\cdot 100 = 1000 .

Check you’ve got it: what is Var(X+Y) \mathrm{Var}(X + Y) in the order, and why is it not 100+200=300 100 + 200 = 300 ?

With a=b=1 a = b = 1 : 100+200+2⋅100=500 100 + 200 + 2\cdot 100 = 500 . Adding only the variances would treat them as independent, and they are not: the arrival includes the kitchen, so when one gets longer the other does too.

Proof 6: the correlation lies between −1 and 1

What we want to prove

−1≤ρ≤1 -1 \le \rho \le 1 , and ρ=±1 \rho = \pm 1 if and only if Y=aX+b Y = aX + b with probability 1 (the sign of ρ \rho is that of a a ).

Why it matters. Since the correlation is always between −1 and 1, a 0.71 means the same in minutes as in seconds. And the second part says what it measures: how close the points are to a straight line. A 0 does not say there is no relationship, only that it is not linear.

Where we start

From the Cauchy–Schwarz inequality: Cov(X,Y)2≤Var(X) Var(Y) \mathrm{Cov}(X, Y)^2 \le \mathrm{Var}(X)\,\mathrm{Var}(Y) . We prove it with a trick: an expectation of a square is never negative.

Cauchy–Schwarz with a parabola that cannot be negativeThree parabolas in t. The violet one, the order, 100 plus 200 t plus 200 t squared, stays above the axis with minimum 50: negative discriminant. The dashed green one touches the axis at one point: discriminant 0, correlation plus or minus 1. The dotted red one would cross the axis and give a negative expectation of a square: impossible.−500100200300−2−1.5−1−0.500.51tq(t)violet minimum: 50 > 0order: Δ < 0 (|ρ| < 1)Δ = 0: touches 0 (ρ = ±1)Δ > 0: impossible
q(t) = Var(X) + 2t·Cov + t²·Var(Y) is the expectation of a square: it never goes below 0.

Step 1: a parabola that is never negative

Let A=X−μX A = X – \mu_X and B=Y−μY B = Y – \mu_Y . For any real number t t , (A+tB)2≥0 (A + tB)^2 \ge 0 , so its expectation isn’t negative either:

q(t)=E(A+tB)2=E(A2)+2t E(AB)+t2E(B2)=Var(X)+2t Cov(X,Y)+t2 Var(Y)≥0 q(t) = E(A + tB)^2 = E(A^2) + 2t\,E(AB) + t^2E(B^2) = \mathrm{Var}(X) + 2t\,\mathrm{Cov}(X, Y) + t^2\,\mathrm{Var}(Y) \ge 0

Why each term is what it is: expand (A+tB)2=A2+2tAB+t2B2 (A + tB)^2 = A^2 + 2tAB + t^2B^2 and, when taking expectations, t t comes out because it is a number. E(A2) E(A^2) , E(B2) E(B^2) and E(AB) E(AB) are, by definition, the two variances and the covariance.

Step 2: the discriminant

q(t) q(t) is a parabola in t t (with Var(Y)>0 \mathrm{Var}(Y) > 0 ) that never goes below 0, so it touches the axis at one point at most: its discriminant cannot be positive.

(2 Cov(X,Y))2−4 Var(Y) Var(X)≤0  ⟺  Cov(X,Y)2≤Var(X) Var(Y) \big(2\,\mathrm{Cov}(X, Y)\big)^2 – 4\,\mathrm{Var}(Y)\,\mathrm{Var}(X) \le 0 \iff \mathrm{Cov}(X, Y)^2 \le \mathrm{Var}(X)\,\mathrm{Var}(Y)

Step 3: the correlation

Dividing by Var(X)Var(Y)>0 \mathrm{Var}(X)\mathrm{Var}(Y) > 0 : ρ2≤1 \rho^2 \le 1 , that is, −1≤ρ≤1 -1 \le \rho \le 1 .

Step 4: when it is ±1

ρ2=1 \rho^2 = 1 is discriminant 0: the parabola touches the axis at a t0 t_0 . Then E(A+t0B)2=0 E(A + t_0B)^2 = 0 , and a non-negative variable with expectation 0 is 0 with probability 1: A+t0B=0 A + t_0B = 0 , that is, X−μX=−t0(Y−μY) X – \mu_X = -t_0(Y – \mu_Y) , a straight line. Conversely, if Y=aX+b Y = aX + b : Cov(X,Y)=a Var(X) \mathrm{Cov}(X, Y) = a\,\mathrm{Var}(X) and σY=∣a∣σX \sigma_Y = |a|\sigma_X , so ρ=a Var(X)σX ∣a∣σX=a∣a∣=±1 \rho = \frac{a\,\mathrm{Var}(X)}{\sigma_X\,|a|\sigma_X} = \frac{a}{|a|} = \pm 1 .

If in an exam you get a correlation of 1.3, don’t look for an interpretation: there is a mistake in E(XY) E(XY) or in a variance. It is the same warning as a probability greater than 1.

Check it with R

set.seed(2026)
x <- rexp(1e5, 0.1)
round(c(cor(x, 3 * x + 2), cor(x, -x + 20), cor(x, x + rexp(1e5, 0.1))), 4)

Output:

[1]  1.0000 -1.0000  0.7055

1 and −1 for the two straight lines; and for the arrival, which is “the kitchen plus something that doesn’t depend on it”, an intermediate value, 0.71 (it comes out 0.7055; the theory gives 1/2 1/\sqrt{2} ).

Check you’ve got it: where does the correlation of 0.71 between the kitchen and the arrival come from?

With proof 5: Cov(X,X+R)=Var(X)+Cov(X,R)=100+0=100 \mathrm{Cov}(X, X + R) = \mathrm{Var}(X) + \mathrm{Cov}(X, R) = 100 + 0 = 100 , because the kitchen and the delivery are independent. The standard deviations are 10 and 200 \sqrt{200} , so ρ=10010200=12=0.71 \rho = \frac{100}{10\sqrt{200}} = \frac{1}{\sqrt{2}} = 0.71 . It does not reach 1 because the delivery adds something that does not depend on the kitchen.

Proof 7: the sum of independent exponentials is a gamma

What we want to prove

If X X and R R are independent and exp⁡(λ) \exp(\lambda) , then Y=X+R∼gamma(2,λ) Y = X + R \sim \text{gamma}(2, \lambda) . More generally, if X1∼gamma(α1,β) X_1 \sim \text{gamma}(\alpha_1, \beta) and X2∼gamma(α2,β) X_2 \sim \text{gamma}(\alpha_2, \beta) are independent, X1+X2∼gamma(α1+α2,β) X_1 + X_2 \sim \text{gamma}(\alpha_1 + \alpha_2, \beta) .

Why it matters. It is the shortest way to find the distribution of a sum: instead of integrating the joint density over the triangle, you multiply two mgfs. That is why P(Y≤30) P(Y \le 30) comes out with a single pgamma.

Where we start

From the mgf of the exponential (topic 4), φ(t)=λλ−t \varphi(t) = \frac{\lambda}{\lambda – t} for t<λ t < \lambda ; from that of the gamma, (ββ−t)α \left(\frac{\beta}{\beta – t}\right)^\alpha ; from the mgf determining the distribution, and from proof 4 with g(x)=etx g(x) = e^{tx} , h(r)=etr h(r) = e^{tr} .

Step by step

φY(t)=E(et(X+R))=E(etX etR)=E(etX) E(etR)=λλ−t⋅λλ−t=(λλ−t)2,t<λ \varphi_Y(t) = E\big(e^{t(X + R)}\big) = E\big(e^{tX}\,e^{tR}\big) = E\big(e^{tX}\big)\,E\big(e^{tR}\big) = \frac{\lambda}{\lambda – t}\cdot\frac{\lambda}{\lambda – t} = \left(\frac{\lambda}{\lambda – t}\right)^2, \quad t < \lambda

The third equality is independence (proof 4). The result is the mgf of a gamma(2,λ) \text{gamma}(2, \lambda) and, since the mgf determines the distribution, Y∼gamma(2,λ) Y \sim \text{gamma}(2, \lambda) . For two gammas with the same β \beta , the same: (ββ−t)α1(ββ−t)α2=(ββ−t)α1+α2 \left(\frac{\beta}{\beta – t}\right)^{\alpha_1}\left(\frac{\beta}{\beta – t}\right)^{\alpha_2} = \left(\frac{\beta}{\beta – t}\right)^{\alpha_1 + \alpha_2} .

The first two equals signs: the mgf of Y Y is by definition E(etY) E(e^{tY}) , and et(x+r)=etx etr e^{t(x + r)} = e^{tx}\,e^{tr} because an exponent that is a sum splits into a product. That product is a g(X)h(R) g(X)h(R) : that is why proof 4 comes in.

Adding two gammas with different β \beta and saying it is a gamma. The product (β1β1−t)α1(β2β2−t)α2 \left(\frac{\beta_1}{\beta_1 – t}\right)^{\alpha_1}\left(\frac{\beta_2}{\beta_2 – t}\right)^{\alpha_2} is not the mgf of any gamma. The kitchen and the delivery add up to a gamma because they have the same λ \lambda .

Check it with R

set.seed(2026)
y <- rexp(1e5, 0.1) + rexp(1e5, 0.1)
round(c(mean(y <= 30), pgamma(30, 2, 0.1)), 4)
round(c(mean(y), var(y)), 2)            # gamma(2, 0.1): mean 20, variance 200

Output:

[1] 0.8012 0.8009
[1]  20.00 200.64

The simulated proportion of orders arriving within 30 minutes and the gamma’s agree up to the third figure (0.801), and the mean and variance are close to 20 and 200.

Check you’ve got it: if you add a third independent stage, the wait at the door D∼exp⁡(0.1) D \sim \exp(0.1) , what distribution does X+R+D X + R + D have?

A gamma(3, 0.1) \text{gamma}(3,\ 0.1) . The mgf of the sum is the product of the three, (0.10.1−t)3 \left(\frac{0.1}{0.1 – t}\right)^3 , the one of a gamma with α=3 \alpha = 3 and β=0.1 \beta = 0.1 . It works because all three have the same λ \lambda . The mean is 3/0.1=30 3/0.1 = 30 minutes.

Proof 8: the Jacobian of the order

What we want to prove

If X X and R R are independent and exp⁡(λ) \exp(\lambda) , then T=X+R T = X + R and U=XX+R U = \frac{X}{X + R} are independent, with T∼gamma(2,λ) T \sim \text{gamma}(2, \lambda) and U∼U(0,1) U \sim U(0, 1) . And, on the way, the joint density of (X, Y=X+R) (X,\ Y = X + R) is λ2e−λy \lambda^2e^{-\lambda y} on 0<x<y 0 < x < y .

Why it matters. It is the two-dimensional theorem in full, in the order the exam asks for it: support, inverse, Jacobian, substitute and marginals. And it reads in the order: knowing how long it took in total says nothing about what share was kitchen.

Where we start

From the change of variable theorem in two dimensions (theorem 6 in the notes): if (u,v)=h(x,y) (u, v) = h(x, y) is bijective and differentiable, fUV(u,v)=fXY(x(u,v),y(u,v)) ∣J∣ f_{UV}(u, v) = f_{XY}(x(u, v), y(u, v))\,|J| , with J J the determinant of the derivatives of the inverse. And from the joint density of (X,R) (X, R) : by independence, f(x,r)=λe−λx⋅λe−λr=λ2e−λ(x+r) f(x, r) = \lambda e^{-\lambda x}\cdot\lambda e^{-\lambda r} = \lambda^2e^{-\lambda(x + r)} on x>0, r>0 x > 0,\ r > 0 .

The Jacobian measures how much a small patch stretchesOn the left, two equal rectangles in the t and u plane, one at t equals 8 in coral and one at t equals 28 in green. On the right, their images in the x and r plane: two parallelograms, the green one much larger than the coral one, because its area is multiplied by t.0.00.51.0010203040tu010203040010203040x = utr = t(1 − u)t = 8area × 8t = 28area × 28|J| = t
Two equal patches in (t, u) take up different areas in (x, r): the factor is |J| = t.

Step 1: the new support

T=X+R T = X + R takes any positive value. U=X/(X+R) U = X/(X + R) is between 0 and 1, because 0<X<X+R 0 < X < X + R . And each (t,u) (t, u) in (0,∞)×(0,1) (0, \infty)\times(0, 1) corresponds to a single (x,r) (x, r) : the transformation is bijective.

Step 2: the inverse

From u=x/t u = x/t we get x=ut x = ut , and from t=x+r t = x + r we get r=t−x=t(1−u) r = t – x = t(1 – u) .

Step 3: the Jacobian

J=det⁡(∂x∂t∂x∂u∂r∂t∂r∂u)=det⁡(ut1−u−t)=u(−t)−t(1−u)=−t J = \det\begin{pmatrix} \frac{\partial x}{\partial t} & \frac{\partial x}{\partial u} \\[4pt] \frac{\partial r}{\partial t} & \frac{\partial r}{\partial u} \end{pmatrix} = \det\begin{pmatrix} u & t \\ 1 – u & -t \end{pmatrix} = u(-t) – t(1 – u) = -t

∣J∣=t |J| = t . The minus sign is not carried along: it is the one in my anecdote. In the drawing, ∣J∣ |J| is the factor by which the area of a small patch is multiplied when going from (t,u) (t, u) to (x,r) (x, r) : a dt×du dt \times du patch becomes a parallelogram of area t dt du t\,dt\,du , larger the bigger t t is.

Step 4: substitute

f(t,u)=λ2e−λ(ut+t(1−u))⋅t=λ2 t e−λt,t>0, 0<u<1 f(t, u) = \lambda^2e^{-\lambda(ut + t(1 – u))}\cdot t = \lambda^2\,t\,e^{-\lambda t}, \qquad t > 0,\ 0 < u < 1

What substituting does: in λ2e−λ(x+r) \lambda^2e^{-\lambda(x + r)} , x x becomes ut ut and r r becomes t(1−u) t(1 – u) . The exponent simplifies by itself, ut+t−ut=t ut + t – ut = t , and the t t in front is ∣J∣ |J| .

Step 5: the marginals and independence

The joint density is the product of λ2te−λt \lambda^2te^{-\lambda t} (only t t ) times 1 (only u u ) on a rectangle. Integrating:

fT(t)=∫01λ2te−λt du=λ2te−λt∼gamma(2,λ)fU(u)=∫0∞λ2te−λt dt=1∼U(0,1) f_T(t) = \int_0^1 \lambda^2te^{-\lambda t}\,du = \lambda^2te^{-\lambda t} \sim \text{gamma}(2, \lambda) \qquad f_U(u) = \int_0^\infty \lambda^2te^{-\lambda t}\,dt = 1 \sim U(0, 1)

The second integral is 1 because it is the integral of a gamma density. And f(t,u)=fT(t) fU(u) f(t, u) = f_T(t)\,f_U(u) at every point: independent.

On the way: the triangle from the theory

With the transformation (x,r)→(x, y=x+r) (x, r) \to (x,\ y = x + r) , the inverse is x=x x = x , r=y−x r = y – x , and

J=det⁡(10−11)=1,f(x,y)=λ2e−λ(x+(y−x))⋅1=λ2e−λy,0<x<y J = \det\begin{pmatrix} 1 & 0 \\ -1 & 1 \end{pmatrix} = 1, \qquad f(x, y) = \lambda^2e^{-\lambda(x + (y – x))}\cdot 1 = \lambda^2e^{-\lambda y}, \quad 0 < x < y

The condition r>0 r > 0 has become y>x y > x : that is how the triangle is born.

Check it with R

set.seed(2026)
x <- rexp(1e5, 0.1); r <- rexp(1e5, 0.1)
t <- x + r; u <- x / t
round(table(cut(u, c(0, 0.25, 0.5, 0.75, 1))) / 1e5, 3)   # quarters of U
round(cor(t, u), 3)
round(c(mean(t <= 30 & u <= 0.5), pgamma(30, 2, 0.1) * 0.5), 4)

Output:

  (0,0.25] (0.25,0.5] (0.5,0.75]   (0.75,1] 
     0.251      0.249      0.250      0.250 
[1] -0.001
[1] 0.4003 0.4004

How to read it

  • The four quarters of U U each have about 25 % of the orders: it is a uniform.
  • cor(t, u) comes out practically 0. On its own it wouldn’t prove independence (zero correlation isn’t enough), but the third line does put it to the test:
  • P(T≤30, U≤0.5) P(T \le 30,\ U \le 0.5) simulated equals the product P(T≤30)⋅P(U≤0.5) P(T \le 30)\cdot P(U \le 0.5) : the joint distribution also factorises on this event.
Check you’ve got it: what is P(T≤30, U≤0.5) P(T \le 30,\ U \le 0.5) by hand, and what does U≤0.5 U \le 0.5 mean in the order?

By independence, P(T≤30)⋅P(U≤0.5)=0.80⋅0.5=0.40 P(T \le 30)\cdot P(U \le 0.5) = 0.80\cdot 0.5 = 0.40 , the 0.4004 from R: the 0.80 is the gamma from proof 7 and the 0.5, the uniform. U≤0.5 U \le 0.5 means the kitchen took at most half of the total time.

Prove it yourself

Three proofs in the same style. Try each one on paper before opening the solution.

1. Prove that E(E(Y∣X))=E(Y) E\big(E(Y \mid X)\big) = E(Y) when (X,Y) (X, Y) is continuous with density f(x,y) f(x, y) . Use it to compute E(Y) E(Y) in the order knowing that E(Y∣X=x)=x+10 E(Y \mid X = x) = x + 10 .

See the solution

E(Y∣X=x)=∫y f(y∣x) dy=∫y f(x,y)fX(x) dy E(Y \mid X = x) = \int y\,f(y \mid x)\,dy = \int y\,\frac{f(x, y)}{f_X(x)}\,dy is a function of x x . Its expectation, with the density of X X :

E(E(Y∣X))=∫(∫y f(x,y)fX(x) dy)fX(x) dx=∫ ⁣ ⁣∫y f(x,y) dy dx=E(Y) E\big(E(Y \mid X)\big) = \int\left(\int y\,\frac{f(x, y)}{f_X(x)}\,dy\right)f_X(x)\,dx = \int\!\!\int y\,f(x, y)\,dy\,dx = E(Y)

The fX(x) f_X(x) cancels, and what is left is the definition of E(Y) E(Y) with the joint density (proof 4). In the order: E(Y)=E(X+10)=E(X)+10=20 E(Y) = E(X + 10) = E(X) + 10 = 20 , without touching the gamma.

2. If X∼exp⁡(λ1) X \sim \exp(\lambda_1) and R∼exp⁡(λ2) R \sim \exp(\lambda_2) are independent, prove that M=min⁡(X,R)∼exp⁡(λ1+λ2) M = \min(X, R) \sim \exp(\lambda_1 + \lambda_2) . (It is the time until whatever finishes first, the kitchen or a message from the rider.)

See the solution

We work with the tail, P(M>m) P(M > m) , because the minimum is greater than m m if and only if both are. For m>0 m > 0 :

P(M>m)=P(X>m, R>m)=P(X>m) P(R>m)=e−λ1m e−λ2m=e−(λ1+λ2)m P(M > m) = P(X > m,\ R > m) = P(X > m)\,P(R > m) = e^{-\lambda_1m}\,e^{-\lambda_2m} = e^{-(\lambda_1 + \lambda_2)m}

The second equality is independence. Then FM(m)=1−e−(λ1+λ2)m F_M(m) = 1 – e^{-(\lambda_1 + \lambda_2)m} , which is the distribution function of an exp⁡(λ1+λ2) \exp(\lambda_1 + \lambda_2) . With the kitchen and the delivery, min⁡∼exp⁡(0.2) \min \sim \exp(0.2) : a mean of 5 minutes.

3. If X∼gamma(α,β) X \sim \text{gamma}(\alpha, \beta) and c>0 c > 0 , prove with the change of variable theorem that Y=cX∼gamma(α,β/c) Y = cX \sim \text{gamma}(\alpha, \beta/c) . What distribution does the kitchen time have measured in seconds?

See the solution

g(x)=cx g(x) = cx is increasing; the inverse is x=y/c x = y/c , with dxdy=1c \frac{dx}{dy} = \frac{1}{c} , and the support is still y>0 y > 0 :

fY(y)=βαΓ(α)(yc)α−1e−βy/c⋅1c=(β/c)αΓ(α) yα−1e−(β/c)y f_Y(y) = \frac{\beta^\alpha}{\Gamma(\alpha)}\left(\frac{y}{c}\right)^{\alpha – 1}e^{-\beta y/c}\cdot\frac{1}{c} = \frac{(\beta/c)^\alpha}{\Gamma(\alpha)}\,y^{\alpha – 1}e^{-(\beta/c)y}

because 1cα−1⋅1c=1cα \frac{1}{c^{\alpha – 1}}\cdot\frac{1}{c} = \frac{1}{c^\alpha} . It is a gamma(α,β/c) \text{gamma}(\alpha, \beta/c) . The kitchen, exp⁡(0.1)=gamma(1, 0.1) \exp(0.1) = \text{gamma}(1,\ 0.1) , in seconds (c=60 c = 60 ) is gamma(1, 0.1/60)=exp⁡(1/600) \text{gamma}(1,\ 0.1/60) = \exp(1/600) : a mean of 600 seconds, the usual 10 minutes.

When to use each result

You are asked for…Use…
The density of g(X) g(X) with g g monotonicProof 1 (fX(g−1)∣(g−1)′∣ f_X(g^{-1})\lvert (g^{-1})' \rvert )
The density of X2 X^2 , ∣X∣ \lvert X \rvert or another g g that goes up and downBack to FY F_Y and differentiate (proof 2)
Simulating a distribution with runifThe inverse of F F (proof 3)
E(XY) E(XY) or E(g(X)h(Y)) E(g(X)h(Y)) If independent, the product; if not, the double integral
The variance of a sum or a differencea2σX2+b2σY2+2ab Cov a^2\sigma_X^2 + b^2\sigma_Y^2 + 2ab\,\mathrm{Cov} (proof 5)
That a correlation doesn’t depend on the unitsProof 5, part 3
That ∣ρ∣≤1 \lvert\rho\rvert \le 1 Cauchy–Schwarz with the parabola (proof 6)
The distribution of a sum of independent variablesThe product of mgfs (proof 7)
The distribution of (U,V)=h(X,Y) (U, V) = h(X, Y) Support, inverse, Jacobian, substitute (proof 8)

Typical mistakes when proving

In the one-dimensional change of variable, writing fX(g(y)) f_X(g(y)) instead of fX(g−1(y)) f_X(g^{-1}(y)) . What is evaluated in the old density is the inverse: the value of x x that produces y y .

Computing the Jacobian with the derivatives of the direct transformation (∂u/∂x \partial u/\partial x …) instead of those of the inverse. If you do, you get 1/∣J∣ 1/|J| . If the direct one is easier for you, fine, but then you have to divide.

Forgetting the support. “f(t,u)=λ2te−λt f(t, u) = \lambda^2te^{-\lambda t} ” without “t>0, 0<u<1 t > 0,\ 0 < u < 1 ” is not a complete answer, and it is exactly what lets you see that U U is uniform.

At the end of any proof that gives a density, integrate the result in your head (or with integrate): if it doesn’t give 1, there is a mistake earlier, almost always in a limit or in a Jacobian.

Try it in the R playground

Open the site’s R playground (or RStudio) and paste this script. It checks five of the eight proofs with simulations:

set.seed(1)
n <- 1e5
# 2. Z^2 is a chi-squared with 1 degree of freedom
z2 <- rnorm(n)^2
c(mean(z2 <= 1), pchisq(1, 1))
# 3. The inverse of F: -10 log(U) is an exp(0.1)
x <- -10 * log(runif(n)); c(mean(x), sd(x))
# 5 and 6. The correlation doesn't change with units and lives between -1 and 1
y <- x + rexp(n, 0.1)
c(cor(x, y), cor(60 * x, y / 60), cor(x, 5 - 3 * x))
# 7. The sum of two exponentials is a gamma(2, 0.1)
hist(y, freq = FALSE, breaks = 60); curve(dgamma(x, 2, 0.1), add = TRUE, col = "red", lwd = 2)
# 8. The kitchen fraction is uniform and independent of the total
u <- x / y; hist(u, freq = FALSE); c(cor(u, y), mean(u <= 0.5 & y <= 30), 0.5 * pgamma(30, 2, 0.1))

What to look at:

  1. In the first line of results, the two numbers should be close: P(Z2≤1)=P(∣Z∣≤1)≈0.68 P(Z^2 \le 1) = P(|Z| \le 1) \approx 0.68 , the rule from topic 5.
  2. cor(60 * x, y / 60) is the same as cor(x, y): going from minutes to seconds or hours doesn’t touch the correlation.
  3. cor(x, 5 - 3 * x) gives exactly −1: a decreasing straight line.
  4. Change the delivery rate to 0.05: the histogram of y stops following the gamma(2, 0.1) (and stops being gamma), and that of u stops being flat.

Summary

ProofResultThe key
1. Change of variablefY=fX(g−1)∣(g−1)′∣ f_Y = f_X(g^{-1})\lvert (g^{-1})' \rvert With g g decreasing, the inequality flips
2. Z2 Z^2 χ2(1)=gamma(1/2, 1/2) \chi^2(1) = \text{gamma}(1/2,\ 1/2) Two branches, ±w \pm\sqrt{w}
3. Inverse of F F F(X)∼U(0,1) F(X) \sim U(0, 1) , F−1(U)∼F F^{-1}(U) \sim F An increasing F F keeps inequalities
4. ExpectationsE(aX+bY) E(aX + bY) linear; E(g(X)h(Y)) E(g(X)h(Y)) product with independenceThe marginal and f=fXfY f = f_Xf_Y
5. Variance and covariancea2σX2+b2σY2+2ab Cov a^2\sigma_X^2 + b^2\sigma_Y^2 + 2ab\,\mathrm{Cov} ; Cov(aX+b,cY+d)=ac Cov \mathrm{Cov}(aX + b, cY + d) = ac\,\mathrm{Cov} Added constants go away
6. ∣ρ∣≤1 \lvert\rho\rvert \le 1 Cauchy–SchwarzA parabola that doesn’t go below 0
7. Sum of exponentialsgamma(2,λ) \text{gamma}(2, \lambda) Product of mgfs
8. JacobianT T gamma, U U uniform, independent∣J∣=t \lvert J \rvert = t and the rectangular support

Three ideas to take away:

  1. Every transformation starts with the support: where the new variable lives. Without it, neither the density nor independence can be read.
  2. The absolute value of the Jacobian is not decoration. It is what turns a change of ruler into a density that integrates to 1.
  3. Independence works in the first step of each proof: f=fXfY f = f_Xf_Y . Without it, E(XY) E(XY) doesn’t split and the covariance doesn’t vanish.

To put it into practice, the R practice computes all this with integrate, Vectorize and simulations, and the exam-style exercises mix proofs and R as in the EC2.

Next step: practiceTransformations and joint distributions in R — practice with runif, integrate inside integrate and the bivariate normal of the delivery (and the Vectorize I was missing)

Did this article help you? Here is how you can support SergioLearns →