Cumulative Distribution Function Practice Problems - GeeksforGeeks

Cumulative Distribution Function Practice Problems

Last Updated : 26 Oct, 2026

A Cumulative Distribution Function (CDF) is a function that gives the probability that a random variable X takes a value less than or equal to a given value \(x\).

Solved Examples

Example 1: Consider a random variable X representing the number of the heads obtained in the two coin flips. Calculate the CDF F(x) of X.

Solution:

The possible values of X are 0, 1 and 2. The probabilities are:

P(X=0) = \frac{1}{4} \quad \text{(no heads)}
P(X=1) = \frac{1}{2} \quad \text{(one head)}
P(X=2) = \frac{1}{4} \quad \text{(two heads)}
The CDF F(x) is:
F(x) = \begin{cases} 0 & \text{if } x < 0 \\ \frac{1}{4} & \text{if } 0 \leq x < 1 \\ \frac{3}{4} & \text{if } 1 \leq x < 2 \\ 1 & \text{if } x \geq 2 \\ \end{cases}

Example 2: Let X be a continuous random variable with the PDF f(x) = 2x for the 0 ≤ x ≤ 1. Find the CDF F(x).

Solution:

To find the CDF integrate the PDF:

F(x) = \int_{-\infty}^{x} f(t) \, dt = \int_{0}^{x} 2t \, dt = x^2 \quad \text{for } 0 \leq x \leq 1
Thus, the CDF is:
F(x) = \begin{cases} 0 & \text{if } x < 0 \\ x^2 & \text{if } 0 \leq x \leq 1 \\ 1 & \text{if } x > 1 \\ \end{cases}

Example 3: Given the CDF F(x) = 1 - e^{-x} for x ≥ 0 find the probability that X lies between the 1 and 2.

Solution:

The probability that X lies between the 1 and 2 is:

P(1 ≤ X ≤ 2) = F(2) - F(1)
Calculate:
F(2) = 1 - e^{-2} \quad \text{and} \quad F(1) = 1 - e^{-1}
P(1 \leq X \leq 2) = (1 - e^{-2}) - (1 - e^{-1}) = e^{-1} - e^{-2}

Example 4: Let X be a mixed random variable with the following distribution: P(X=0) = 0.2, P(X=1) = 0.3 and the continuous part is uniformly distributed over [2, 3]. Find the CDF F(x).

Solution:

For x < 0, F(x) = 0.
For 0 ≤ x < 1, F(x) = 0.2.
For 1 ≤ x < 2, F(x) = 0.5.
For 2 ≤ x < 3 the continuous part applies:
F(x) = 0.5 + 0.5 ✕ (x - 2) = 0.5 + 0.5x - 1
Thus, F(x) = 0.5x - 0.5 for 2 ≤ x ≤ 3.
For x \geq 3, F(x) = 1.

Example 5: Given a PDF f(x) = \frac{3}{4}(1 - x^2) for the -1 ≤ x ≤ 1 find the CDF F(x).

Solution:

Integrate the PDF to find the CDF:
F(x) = \int_{-\infty}^{x} f(t) \, dt = \int_{-1}^{x} \frac{3}{4}(1 - t^2) \, dt
Solving the integral:
F(x) = \frac{3}{4} \left[t - \frac{t^3}{3}\right]_{-1}^{x} = \frac{3}{4} \left(x - \frac{x^3}{3} + \frac{2}{3}\right)
The CDF (F(x)) is:
F(x) = \begin{cases} 0 & \text{if } x < -1 \\ \frac{3}{4} \left(x - \frac{x^3}{3} + \frac{2}{3}\right) & \text{if } -1 \leq x \leq 1 \\ 1 & \text{if } x > 1 \\ \end{cases}

Practice Questions

1. Find the CDF of a random variable X representing the number of the heads in three coin flips.
2. Determine the CDF for a continuous random variable X with the PDF f(x) = 3x2 for 0 ≤ x ≤ 1. 3. Calculate the probability that X is less than or equal to the 4 given the CDF F(x) = 1 - e-x for x ≥ 0.
4. Find the CDF for the random variable X uniformly distributed over the interval [2, 5].
5. Given the CDF F(x) for a random variable X find the PDF by differentiating the CDF.
6. Use the CDF F(x) = 1 - e-x to find the probability that X lies between the 2 and 3.
7. For a discrete random variable X taking values 1, 2 and 3 with the probabilities 0.2, 0.5 and 0.3 respectively find the CDF F(x).
8.Calculate the CDF for a normal distribution with the mean 0 and standard deviation 1 at x = 1.
9.Given a random variable X with the PDF f(x) = \frac{1}{2} for 0 ≤ x ≤ 2 find the CDF F(x)
10. Determine the probability that a continuous random variable X with the PDF f(x) = 4x for 0 ≤ x ≤ 1 is greater than 0.5.

Answer Key
1. 0, \frac{1}{8},\frac{1}{2},\frac{7}{8},1
2. x3
3. 0.9817
4. \frac{x-2}{3}
5. F'_{X}(x)
6. 0.085.
7. 0.2, 0.7, 1
8. 0.8413
9. \frac{x}{2}
10. 0.75

Comment