Preview

A lesson from Essential Probability & Statistics for ML

£29/month

£29/month£29/month or £249/year · 30-day money-back guarantee

Get full access

Our content is best on a larger screen

Marginal PDFs

Marginal PDFs on a rectangle

Explanation

A joint PDF f(x,y)f(x, y) determines every probability about XX and YY, including probabilities about XX alone. How do we find the PDF of XX alone from the joint PDF?

For discrete random variables, the event {X=x}\{X = x\} is the row xx of the joint PMF's table, and the marginal PMF of XX sums out YY across that row:

pX(x)=∑yp(x,y)p_X(x) = \sum_y p(x, y)

For continuous random variables, an integral takes the place of the sum: we integrate out yy, which leaves a function of xx alone. The diagram below builds this up on one joint PDF.

x
y
z
1
2
3
4
1

Step 1: The solid under f

The surface z=f(x,y) is the graph of a joint PDF on the rectangle

0≤x≤4,0≤y≤1.

The solid under it has volume 1.

Step 2: An event about X is a strip

Take an event about X alone, such as 1<X<3. It places no condition on Y, so its region R is a strip across the rectangle, the continuous version of a row of a joint PMF's table.

Its probability is the volume of the solid over R:

P(1<X<3)=∬Rf(x,y)dA.

Step 3: The area under a cross-section

The face under the cross-section at x=2 has area

∫01f(2,y)dy=13.

The volume over R is the integral of the areas of these faces from x=1 to x=3, so the area of each face is the quantity we need. The point on the back wall is at that height.

Step 4: The PDF of X

Move the slider to move the cross-section from x=0 to x=4. The height of the point on the back wall is always the area under the cross-section, and the point traces a curve.

The area under the curve from 1 to 3 is the volume over R, so the curve is the graph of the PDF of X, written fX.

Marginal PDFs

Theorem

For continuous random variables XX and YY with joint PDF f(x,y)f(x, y), the marginal PDFs of XX and YY, the PDFs of each alone, are

fX(x)=∫−∞∞f(x,y) dyfY(y)=∫−∞∞f(x,y) dx\begin{align*} f_X(x) &= \int_{-\infty}^{\infty} f(x, y)\,dy \\[6pt] f_Y(y) &= \int_{-\infty}^{\infty} f(x, y)\,dx \end{align*}

Since ff is 00 off its support, at each xx the integral for fX(x)f_X(x) is taken only over the yy with (x,y)(x, y) in the support, and fX(x)=0f_X(x) = 0 at any xx where there are none. Likewise, the integral for fY(y)f_Y(y) is taken only over the xx with (x,y)(x, y) in the support.

Example

(X,Y)(X, Y) has joint PDF

f(x,y)={13(x+y)0≤x≤1, 0≤y≤20otherwisef(x, y) = \begin{cases} \dfrac{1}{3}(x + y) & 0 \le x \le 1,\ 0 \le y \le 2 \\[6pt] 0 & \text{otherwise} \end{cases}

Find the marginal PDFs fXf_X and fYf_Y.

Solution

The marginal PDF of XX integrates out yy. The support is the rectangle 0≤x≤10 \le x \le 1, 0≤y≤20 \le y \le 2, so at each xx in [0,1][0, 1] we integrate from y=0y = 0 to y=2y = 2:

fX(x)=∫0213(x+y) dy=13[xy+y22]y=0y=2=13(2x+2)=23(x+1)\begin{align*} f_X(x) &= \int_0^2 \dfrac{1}{3}(x + y)\,dy \\[6pt] &= \dfrac{1}{3}\Big[xy + \dfrac{y^2}{2}\Big]_{y=0}^{y=2} \\[6pt] &= \dfrac{1}{3}(2x + 2) \\[6pt] &= \dfrac{2}{3}(x + 1) \end{align*}

The marginal PDF of YY integrates out xx. At each yy in [0,2][0, 2] we integrate from x=0x = 0 to x=1x = 1:

fY(y)=∫0113(x+y) dx=13[x22+xy]x=0x=1=13(12+y)=1+2y6\begin{align*} f_Y(y) &= \int_0^1 \dfrac{1}{3}(x + y)\,dx \\[6pt] &= \dfrac{1}{3}\Big[\dfrac{x^2}{2} + xy\Big]_{x=0}^{x=1} \\[6pt] &= \dfrac{1}{3}\left(\dfrac{1}{2} + y\right) \\[6pt] &= \dfrac{1 + 2y}{6} \end{align*}

Each marginal PDF is 00 off its own interval, so

fX(x)={23(x+1)0≤x≤10otherwisef_X(x) = \begin{cases} \dfrac{2}{3}(x + 1) & 0 \le x \le 1 \\[6pt] 0 & \text{otherwise} \end{cases}

and

fY(y)={1+2y60≤y≤20otherwisef_Y(y) = \begin{cases} \dfrac{1 + 2y}{6} & 0 \le y \le 2 \\[6pt] 0 & \text{otherwise} \end{cases}

Practice questions

5 questions

(X,Y)(X, Y) has joint PDF

f(x,y)={38(x+y2)0≤x≤2, 0≤y≤10otherwisef(x, y) = \begin{cases} \dfrac{3}{8}(x + y^2) & 0 \le x \le 2,\ 0 \le y \le 1 \\[6pt] 0 & \text{otherwise} \end{cases}

Which integral gives the marginal PDF fX(x)f_X(x) for 0≤x≤20 \le x \le 2?

Select the correct answer:

+ 4 more questions · unlocked with a subscription

When the support is not a rectangle

Explanation

At each xx, the value fX(x)f_X(x) of the marginal PDF is the area of the face under the cross-section at xx. On a rectangle every face has the same width, but off a rectangle the width changes with xx. The diagram below shows what this does to each marginal PDF.

x
y
z
1
1
2

Step 1: A constant joint PDF

The joint PDF is f(x,y)=2 on the triangle

0≤y≤x≤1

and 0 elsewhere, so the solid under it is a slab of height 2. The triangle is half of a unit square, so the slab has volume 1.

Step 2: The marginal PDF of X

As for a double integral over a general region, the face under the cross-section at x reaches from y=0 to y=x, so its area is 2×x:

fX(x)=∫0x2dy=2x

The point on the back wall is at this height. X is more likely to lie near 1 than near 0.

Step 3: The graph of fX

Move the slider to move the face from x=0 to x=1. Its width is x, so its area 2x grows with x, and the point on the back wall traces a line, the graph of fX.

The integral for fX(x)f_X(x) has limits −∞-\infty and ∞\infty, but ff is 00 off its support, so only the yy with (x,y)(x, y) in the support contribute. We find these limits of integration exactly as in calculus, by describing the support.

Key Point

For fXf_X, always use vertical lines: xx is fixed and we integrate over yy. For fYf_Y, always use horizontal lines: yy is fixed and we integrate over xx.

Finding a marginal PDF on any support

Procedure

  1. Describe the support:

    • For fXf_X, with vertical lines: a≤x≤ba \le x \le b, g1(x)≤y≤g2(x)g_1(x) \le y \le g_2(x).
    • For fYf_Y, with horizontal lines: c≤y≤dc \le y \le d, h1(y)≤x≤h2(y)h_1(y) \le x \le h_2(y).
  2. Integrate out the other variable between the curves. The numbers give the range of the formula, and the marginal PDF is 00 outside it:

    fX(x)=∫g1(x)g2(x)f(x,y) dyfor a≤x≤bfY(y)=∫h1(y)h2(y)f(x,y) dxfor c≤y≤d\begin{align*} f_X(x) &= \int_{g_1(x)}^{g_2(x)} f(x, y)\,dy \quad \text{for } a \le x \le b \\[6pt] f_Y(y) &= \int_{h_1(y)}^{h_2(y)} f(x, y)\,dx \quad \text{for } c \le y \le d \end{align*}

Example

(X,Y)(X, Y) has joint PDF

f(x,y)={6x0≤x≤y≤10otherwisef(x, y) = \begin{cases} 6x & 0 \le x \le y \le 1 \\[6pt] 0 & \text{otherwise} \end{cases}

Find the marginal PDFs fXf_X and fYf_Y.

Solution

The support is the triangle with corners (0,0)(0, 0), (0,1)(0, 1) and (1,1)(1, 1). It covers every xx and every yy in [0,1][0, 1], so both marginal PDFs are 00 outside [0,1][0, 1].

0.510.51
x
y
y=x
y=1
x
y

For fXf_X we use vertical lines. The red vertical line at xx enters the support on y=xy = x and leaves on y=1y = 1, so the support is

0≤x≤1,x≤y≤10 \le x \le 1, \quad x \le y \le 1

We integrate out yy between these limits, and 6x6x is a constant in yy:

fX(x)=∫x16x dy=[6xy]y=xy=1=6x−6x2=6x(1−x)\begin{align*} f_X(x) &= \int_x^1 6x\,dy \\[6pt] &= \Big[6xy\Big]_{y=x}^{y=1} \\[6pt] &= 6x - 6x^2 \\[6pt] &= 6x(1 - x) \end{align*}

For fYf_Y we use horizontal lines. The purple horizontal line at yy enters the support on x=0x = 0 and leaves on x=yx = y, so the support is

0≤y≤1,0≤x≤y0 \le y \le 1, \quad 0 \le x \le y

We integrate out xx between these limits:

fY(y)=∫0y6x dx=[3x2]x=0x=y=3y2\begin{align*} f_Y(y) &= \int_0^y 6x\,dx \\[6pt] &= \Big[3x^2\Big]_{x=0}^{x=y} \\[6pt] &= 3y^2 \end{align*}

So the marginal PDF of XX is

fX(x)={6x(1−x)0≤x≤10otherwisef_X(x) = \begin{cases} 6x(1 - x) & 0 \le x \le 1 \\[6pt] 0 & \text{otherwise} \end{cases}

and the marginal PDF of YY is

fY(y)={3y20≤y≤10otherwisef_Y(y) = \begin{cases} 3y^2 & 0 \le y \le 1 \\[6pt] 0 & \text{otherwise} \end{cases}

Practice questions

5 questions

(X,Y)(X, Y) has joint PDF

f(x,y)={34y0≤y≤x≤20otherwisef(x, y) = \begin{cases} \dfrac{3}{4}y & 0 \le y \le x \le 2 \\[6pt] 0 & \text{otherwise} \end{cases}

Which integral gives the marginal PDF fX(x)f_X(x) for 0≤x≤20 \le x \le 2?

Select the correct answer:

+ 4 more questions · unlocked with a subscription

Memory is built by recalling, not by reading.

Every time you pull an answer from memory, the memory gets stronger. Reading doesn't do that. Nodeledge asks you questions on every step of every lesson, then asks again after days, weeks and months.

Get full access

£29/month or £249/year · 30-day money-back guarantee

See the learning path