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

The CDF of a continuous random variable

The CDF from a PDF

Explanation

How do we find the CDF F(x)=P(X≤x)F(x) = P(X \le x) of a continuous random variable XX from its PDF ff?

P(X≤x)P(X \le x) is the area under ff to the left of xx. As xx moves right this area builds up, so FF is an accumulation function of ff, starting from −∞-\infty.

Since P(X=x)=0P(X = x) = 0, the area builds up with no jumps, so the graph of FF is a continuous, non-decreasing curve rather than a step function.

The diagram below builds up FF for one PDF.

0.5
1
x
0.5
1
x
0
0
0.5
1
1
2
f(x)
F(x)
x

The top graph is the PDF

f(x)=2x,0≤x≤1

and the bottom graph is its CDF F. Drag the red point x to the right. The shaded area to the left of x is F(x), the height of the point below.

x=−0.30,F(x)=0.00
The CDF from a PDF

Theorem

If XX is a continuous random variable with PDF ff, its CDF is

F(x)=P(X≤x)=∫−∞xf(t) dtF(x) = P(X \le x) = \int_{-\infty}^{x} f(t)\,dt

Since f=0f = 0 off the support, for a support [a,b][a, b] this is

F(x)={0x<a∫axf(t) dta≤x≤b1x>bF(x) = \begin{cases} 0 & x < a \\ \displaystyle\int_a^x f(t)\,dt & a \le x \le b \\ 1 & x > b \end{cases}

A support such as [0,∞)[0, \infty) has no right end, so only the first two pieces appear.

As for any CDF, P(c<X≤d)=F(d)−F(c)P(c < X \le d) = F(d) - F(c) for numbers c<dc < d.

Example

A random variable XX has PDF

f(x)={32(1−x2)0≤x≤10otherwisef(x) = \begin{cases} \dfrac{3}{2}(1 - x^2) & 0 \le x \le 1 \\[6pt] 0 & \text{otherwise} \end{cases}

Find the CDF FF of XX, then F(0.5)F(0.5).

Solution

The support is [0,1][0, 1], so FF has three pieces. Left of the support no area has built up, so F(x)=0F(x) = 0 for x<0x < 0.

On the support, the integral starts at the support's left end, 00:

F(x)=∫0x32(1−t2) dt=32[t−t33]0x=32(x−x33)=3x−x32\begin{align*} F(x) &= \int_0^x \dfrac{3}{2}(1 - t^2)\,dt \\ &= \dfrac{3}{2}\left[t - \dfrac{t^3}{3}\right]_0^x \\ &= \dfrac{3}{2}\left(x - \dfrac{x^3}{3}\right) \\ &= \dfrac{3x - x^3}{2} \end{align*}

At the right end, F(1)=3−12=1F(1) = \dfrac{3 - 1}{2} = 1, so all the area has built up, and F(x)=1F(x) = 1 for x>1x > 1. Together:

F(x)={0x<03x−x320≤x≤11x>1F(x) = \begin{cases} 0 & x < 0 \\ \dfrac{3x - x^3}{2} & 0 \le x \le 1 \\ 1 & x > 1 \end{cases}

Now 0.50.5 lies in the support, so we use the middle piece:

F(0.5)=3(0.5)−0.532=1.5−0.1252=0.6875F(0.5) = \dfrac{3(0.5) - 0.5^3}{2} = \dfrac{1.5 - 0.125}{2} = 0.6875

Practice questions

4 questions

A random variable XX has PDF

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

What is the CDF FF of XX?

Select the correct answer:

+ 3 more questions · unlocked with a subscription

The PDF from a CDF

Explanation

Going the other way, how do we recover the PDF ff from a CDF FF?

FF is an accumulation function of ff, so by the Fundamental Theorem of Calculus, Part 1, differentiating FF gives back ff.

The PDF from a CDF

Theorem

If a continuous random variable XX has CDF FF, its PDF is

f(x)=F′(x)f(x) = F'(x)

at every xx where FF is differentiable.

A CDF is usually given in pieces, so we differentiate it one piece at a time, keeping each piece's inequalities. Where FF is flat, f(x)=0f(x) = 0. The points where pieces meet do not matter, since a single point adds no area.

Example

A random variable XX has CDF

F(x)={0x<02x−x20≤x≤11x>1F(x) = \begin{cases} 0 & x < 0 \\ 2x - x^2 & 0 \le x \le 1 \\ 1 & x > 1 \end{cases}

Find the PDF ff of XX.

Solution

We differentiate each piece of FF. The pieces 00 and 11 are flat, so f(x)=0f(x) = 0 for x<0x < 0 and for x>1x > 1. On the middle piece,

f(x)=ddx(2x−x2)=2−2xf(x) = \dfrac{d}{dx}\left(2x - x^2\right) = 2 - 2x

Keeping each piece's inequalities, and combining the two flat pieces:

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

Practice questions

4 questions

A random variable XX has CDF

F(x)={0x<0x30≤x≤11x>1F(x) = \begin{cases} 0 & x < 0 \\ x^3 & 0 \le x \le 1 \\ 1 & x > 1 \end{cases}

What is the PDF ff of XX?

Select the correct answer:

+ 3 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