Joint Continuous Distributions
Joint densities, conditional density functions, marginalisation by integration and independence.
Assumes you know
Joint Continuous Distributions
Intuition first
With one continuous variable, probability is an area under a curve. With two, it becomes a volume under a surface. The joint density is a height above the plane, and the probability of landing in a region is the volume sitting over it.
Everything from the discrete case carries across with sums replaced by integrals. Marginalising means integrating out the variable you do not care about. Conditioning means slicing the surface at a fixed value and renormalising so the slice integrates to 1.
The one genuinely new difficulty is the limits of integration. When the support is not a rectangle — say — getting the limits right is most of the work, and sketching the region first is not optional advice but the fastest route to a correct answer.
Joint density
with
| Symbol | Meaning | Read aloud |
|---|---|---|
| f(x,y) | Joint density | f of x y |
| fₓ(x) | Marginal density of X | f sub X of x |
| f(y|x) | Conditional density of Y given X = x | f of y given x |
| ∬ | Double integral over a region | double integral |
Marginals: integrate out
Conditionals: slice and renormalise
The division by is what makes the slice a valid density integrating to 1.
Independence holds exactly when the joint factorises:
Solved problem 1 · A triangular support, worked completely
on the region , zero elsewhere.
(a) Verify it is a density. (b) Find both marginals. (c) Find . (d) Determine whether and are independent. (e) Find .
Step 1 — sketch the region, then choose an integration order
The support is the triangle with vertices , , — above the line inside the unit square.
Two valid orders:
Step 2 — part (a): verify normalisation
Integrate with outer, inner:
Step 3 — part (b): marginal of X
Fix and integrate from to 1:
Check:
Step 4 — marginal of Y
Fix and integrate from 0 to :
Check:
Step 5 — part (c): the conditional density
Verify it integrates to 1 over its range:
Step 6 — part (d): independence
which is not . So not independent.
The structural reason is decisive on its own: the support is a triangle, so the range of depends on . Knowing forces ; knowing allows .
Step 7 — part (e): P(Y > 2X)
We need the part of the triangle also satisfying . Since implies for positive , the region is simply , so .
Inner integral:
Outer:
Answer
(a) integrates to 1 ✓; (b) , ; (c) on ; (d) not independent; (e) .
Expectations over joint distributions
Covariance follows as before:
Solved problem 2 · Covariance from a joint density
For the distribution above, compute .
Step 1 — E[X] from its marginal
Step 2 — E[Y] from its marginal
Step 3 — E[XY] from the joint
Inner:
Outer:
Step 4 — assemble
Common denominator :
Step 5 — interpret the sign
Positive, as the geometry demands: the constraint means large forces large . The magnitude is small because is confined to and heavily concentrated near 1 — its marginal puts most mass at the top — leaving little room to vary with .
Answer
— small and positive.
import numpy as np
from scipy import integrate
f = lambda x, y: 8 * x * y
# Normalisation over 0 < x < y < 1, integrating x from 0 to y.
total, _ = integrate.dblquad(f, 0, 1, lambda y: 0, lambda y: y)
print(f"total probability {total:.10f}")
# Marginals, checked against the closed forms.
for x0 in (0.2, 0.5, 0.8):
num, _ = integrate.quad(lambda y: f(x0, y), x0, 1)
print(f"f_X({x0}) numeric {num:.6f} closed form {4*x0*(1-x0**2):.6f}")
# P(Y > 2X).
p, _ = integrate.dblquad(f, 0, 0.5, lambda x: 2*x, lambda x: 1)
print(f"\nP(Y > 2X) {p:.6f} theory {0.25:.6f}")
# Moments and covariance.
EX, _ = integrate.quad(lambda x: x * 4*x*(1-x**2), 0, 1)
EY, _ = integrate.quad(lambda y: y * 4*y**3, 0, 1)
EXY, _ = integrate.dblquad(lambda x, y: x*y*f(x, y), 0, 1, lambda y: 0, lambda y: y)
print(f"\nE[X] {EX:.6f} (8/15 = {8/15:.6f})")
print(f"E[Y] {EY:.6f} (4/5 = {0.8:.6f})")
print(f"Cov {EXY - EX*EY:.6f} (4/225 = {4/225:.6f})")
# Rejection sampling as an independent check.
rng = np.random.default_rng(0)
x, y = rng.random(4_000_000), rng.random(4_000_000)
keep = x < y
w = 8 * x[keep] * y[keep] # importance weights
w /= w.sum()
idx = rng.choice(keep.sum(), size=500_000, p=w)
xs, ys = x[keep][idx], y[keep][idx]
print(f"\nsampled: E[X] {xs.mean():.4f} E[Y] {ys.mean():.4f} Cov {np.cov(xs, ys)[0,1]:.5f}")Exercise 1
on the unit square . Find and determine independence.
Show solutionHide solution
First confirm it is a density:
Marginal of :
By symmetry .
Test factorisation:
which is not . So and are dependent.
Note that here the support is a rectangle, so the rectangle test does not settle it — the dependence comes from the algebraic form, since is a sum rather than a product. A joint density is separable only if it factorises as , and a sum never does.
Exercise 2
and are independent . Find and .
Show solutionHide solution
Independence gives on the unit square, so probabilities are just areas.
First part. The region inside the unit square is the triangle below the diagonal from to :
Second part. The region excludes the area above the hyperbola . That curve enters the square at (where ) and leaves at (where ).
The contrast is instructive: the sum splits the square evenly, while the product is below 0.5 nearly 85% of the time. Multiplying two numbers less than 1 usually gives something much smaller, so products of uniforms concentrate near zero — which is why , used in inverse transform sampling, spreads them back out.