Guozhen AIGlobal AI field notes and model intelligence

English translation

Set parameters

Published:

Category: Probability Theory for Beginners

Read time: 4 min

Reads: 0

Lesson #6Views are counted together with the original Chinese articleImages are preserved from the source page

Concept Diagram: Cumulative Distribution Function and Probability Density Function

The PDF describes density; the CDF describes cumulative probability. In continuous distributions, the density value at a single point does not equal the probability of that point.

Verification Diagram: CDF vs. PDF

I’ll use area under the curve to interpret probability. If you see a PDF value greater than 1, don’t immediately assume it’s an error.

In the previous article, we introduced the fundamental concept of random variables and their classification—namely, discrete and continuous random variables. In this article, we delve deeper into two essential tools associated with these variables: the Cumulative Distribution Function (CDF) and the Probability Density Function (PDF). These concepts lay the groundwork for our further exploration of probability distributions—a prerequisite for our next article, where we’ll examine common distributions such as the binomial distribution.

1. Cumulative Distribution Function (CDF)

The Cumulative Distribution Function quantifies the probability that a random variable takes on a value less than or equal to a given threshold. Specifically, the CDF of a random variable XX, denoted FX(x)F_X(x), gives the probability that XX is no greater than xx:

FX(x)=P(Xx)F_X(x) = P(X \leq x)

CDF–PDF Concept Card

When learning about the CDF and PDF, remember: one answers “What is the cumulative probability over an interval?”, while the other describes “How dense is the probability near a continuous value?”

For a discrete random variable XX, its CDF is defined as:

FX(x)=P(Xx)=xixP(X=xi)F_X(x) = P(X \leq x) = \sum_{x_i \leq x} P(X = x_i)

For a continuous random variable XX, the CDF is defined as:

FX(x)=P(Xx)=xfX(t)dtF_X(x) = P(X \leq x) = \int_{-\infty}^x f_X(t)\, dt

where fX(t)f_X(t) is the probability density function (PDF) of XX.

1.1 Example: CDF of a Discrete Random Variable

Consider a simple experiment: rolling a fair six-sided die. Let the random variable XX represent the outcome. Then XX takes values in {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}, each with probability P(X=x)=16P(X = x) = \frac{1}{6}. We compute FX(3)F_X(3):

FX(3)=P(X3)=P(X=1)+P(X=2)+P(X=3)=16+16+16=12F_X(3) = P(X \leq 3) = P(X = 1) + P(X = 2) + P(X = 3) = \frac{1}{6} + \frac{1}{6} + \frac{1}{6} = \frac{1}{2}

1.2 Example: CDF of a Continuous Random Variable

Let XX be a continuous random variable following the uniform distribution U(0,1)U(0, 1). Its PDF fX(x)f_X(x) is:

fX(x)={10x10otherwisef_X(x) = \begin{cases} 1 & 0 \leq x \leq 1 \\ 0 & \text{otherwise} \end{cases}

Then its CDF is:

FX(x)=0x1dt=xfor 0x1F_X(x) = \int_{0}^{x} 1 \, dt = x \quad \text{for } 0 \leq x \leq 1

2. Probability Density Function (PDF)

The Probability Density Function characterizes how probability is distributed across the possible values of a continuous random variable. For discrete random variables, we use the probability mass function (PMF); for continuous ones, we use the PDF.

Probability Reading Map Card

Before reading “Random Variables and Distributions: CDF and PDF”, first glance at the diagram showing the path from problem → reasoning → result. After reading, revisit the diagram to verify whether you can reconstruct the logic step-by-step.

2.1 Definition of the PDF

For a random variable XX with PDF fX(x)f_X(x), the probability that XX falls within an interval [a,b][a, b] is given by:

P(a<Xb)=abfX(x)dxP(a < X \leq b) = \int_{a}^{b} f_X(x)\, dx

A valid PDF satisfies two key properties:

  1. Non-negativity: fX(x)0f_X(x) \geq 0 for all xx.
  2. Unit total area: the integral over the entire real line equals 1:
+fX(x)dx=1\int_{-\infty}^{+\infty} f_X(x)\, dx = 1

2.2 Example: PDF of the Uniform Distribution

Continuing with the U(0,1)U(0,1) example, its PDF is:

fX(x)={10x10otherwisef_X(x) = \begin{cases} 1 & 0 \leq x \leq 1 \\ 0 & \text{otherwise} \end{cases}

This reflects the fact that every value in [0,1][0,1] is equally likely.

3. Relationship Between CDF and PDF

For continuous random variables, the CDF and PDF are intimately linked: the PDF is the derivative of the CDF.

CDF–PDF Application Checklist

To apply “Random Variables and Distributions: CDF and PDF” to your own task, start small—focus on verifying just one critical decision point.

CDF–PDF Application Reflection Card

After studying “Random Variables and Distributions: CDF and PDF”, try adapting it to a scenario of your own—pay special attention to whether inputs, processing steps, and outputs align coherently.

fX(x)=ddxFX(x)f_X(x) = \frac{d}{dx} F_X(x)

Conversely, if the PDF is known, the CDF can be recovered via integration:

FX(x)=xfX(t)dtF_X(x) = \int_{-\infty}^x f_X(t)\, dt

3.1 Example: From PDF to CDF

Recall the U(0,1)U(0,1) PDF fX(x)f_X(x). Its corresponding CDF is:

FX(x)={0x<0x0x11x>1F_X(x) = \begin{cases} 0 & x < 0 \\ x & 0 \leq x \leq 1 \\ 1 & x > 1 \end{cases}

This piecewise definition captures the characteristic shape of the uniform distribution.

3.2 Python Example: Computing CDF and PDF

Below is a simple Python example using scipy to compute and visualize the CDF and PDF of the uniform distribution.

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import uniform

# Set parameters
a, b = 0, 1  # support interval for Uniform(0, 1)

# Generate x values
x = np.linspace(-0.5, 1.5, 100)

# Compute PDF and CDF
pdf = uniform.pdf(x, loc=a, scale=b)
cdf = uniform.cdf(x, loc=a, scale=b)

# Plotting
plt.figure(figsize=(10, 5))

# Plot PDF
plt.subplot(1, 2, 1)
plt.title('Probability Density Function (PDF)')
plt.plot(x, pdf, label='PDF', color='blue')
plt.fill_between(x, pdf, alpha=0.2)
plt.xlim(-0.5, 1.5)
plt.xlabel('x')
plt.ylabel('Density')
plt.axhline(0, color='black', lw=1)
plt.axvline(0, color='black', lw=1)

# Plot CDF
plt.subplot(1, 2, 2)
plt.title('Cumulative Distribution Function (CDF)')
plt.plot(x, cdf, label='CDF', color='orange')
plt.axhline(1, color='black', lw=1)
plt.axvline(1, color='black', lw=1)
plt.xlim(-0.5, 1.5)
plt.xlabel('x')
plt.ylabel('Probability')
plt.axhline(0, color='black')

Continue

Keep reading from here

Browse English site

Reader Messages

Reader messages

Questions, corrections, extra sources, or hands-on results can be left here. No login is required.

Max 800 characters

To reduce spam, each message is checked for length, link count, and posting frequency.

0/800

Messages

0 messages
Loading messages...