Tutorials › VEE Mathematical Statistics › Constructing a CDF from a Density

VEE Mathematical Statistics · Random Variables and Distribution Functions · Tutorial 48 of 880

Constructing a CDF from a Density

Build a CDF from a density by accumulating probability across its support and handling each piece and tail correctly.

Beginner 10 min read

What You'll Learn

  • Translate a density into a CDF using a cumulative integral.
  • Set the CDF to zero below the support and one above it.
  • Integrate piecewise densities over the correct subintervals.
  • Recognize where a CDF is constant because the density is zero.
  • Check a constructed CDF against the total probability and its boundary values.
  • Avoid reversing the integration limits or omitting accumulated probability.

From Density to Cumulative Probability

A density describes how probability is spread across the possible values of a continuous random variable. A cumulative distribution function (CDF) answers a different question: how much probability has accumulated at or below a specified value? To construct the CDF, integrate the density from the lower end of the range up to that value.

The key is to accumulate all probability to the left of \(x\), not just the density at \(x\) or the probability in a small interval around it. When the density is given in pieces, the CDF must also account for each piece already passed. Outside the range where the density is positive, the CDF has constant tails.

Definition: For a continuous random variable \(X\) with density \(f_X\), its cumulative distribution function is \(F_X(x)=P(X\leq x)\). If the density is zero outside the finite support \([a,b]\), then $$ F_X(x)=\int_a^x f_X(t)\,dt \quad \text{for } a\leq x\leq b. $$ Below the support \(F_X(x)=0\), and above the support \(F_X(x)=1\). The integration variable \(t\) is a placeholder; the upper limit \(x\) is the value at which the CDF is being evaluated.

This construction assumes a continuous distribution described completely by a density: \(f_X(t)\geq 0\), and the density integrates to one over its support. A density specified only on \([a,b]\) is taken to be zero elsewhere. The integral formula alone does not describe a distribution that also has point probabilities; such a model would need those probabilities included as well.

Why the Integral Gives the CDF

A density assigns probability to intervals by integration. In particular, for \(r<s\), the probability that \(X\) lies between \(r\) and \(s\) is the area under its density over that interval. To find \(P(X\leq x)\), accumulate that area from the beginning of the support to \(x\).

$$ P(X\leq x)=P(a\leq X\leq x)=\int_a^x f_X(t)\,dt,\qquad a\leq x\leq b. $$

The first equality uses the fact that \(X\) cannot be below \(a\) under this model. The second is the defining probability rule for a density. If \(x<a\), no supported values have accumulated, so the probability is zero. If \(x>b\), the integral has accumulated the entire density, which totals one, so the probability is one.

Construction rule: First identify the full support. On that support, integrate the density from its lower end to \(x\), splitting the integral wherever the density's formula changes. Then attach the constant tails \(0\) below the support and \(1\) above it.

A Reliable Construction Process

1
Identify the support.
Record where the density is positive and where it is zero. The lowest supported value is the starting point for accumulation.
2
Set the lower tail.
For \(x\) below the support, no probability has accumulated, so write \(F_X(x)=0\).
3
Integrate to \(x\).
Within the support, integrate the density from its lower endpoint to \(x\). If the density changes formula, split the integral at each change and include the probability accumulated in earlier pieces.
4
Set the upper tail and check.
Above the support, the CDF is one. Check that the density integrates to one and that the constructed CDF reaches one at the upper endpoint.

Worked Constructions

Worked Example: A Triangular Density on a Finite Interval

A hypothetical claim amount \(X\), measured in thousands of dollars, has density \(f_X(x)=2x/9\) for \(0\leq x\leq 3\), and zero otherwise. Construct its CDF and find \(F_X(1.5)\). The assumed distribution is continuous with support \([0,3]\); no interest or mortality assumptions are involved.

Method: integrate from the lower support endpoint. First verify the density has total probability one:

$$ \int_0^3 \frac{2x}{9}\,dx =\left[\frac{x^2}{9}\right]_0^3 =\frac{9}{9}-0 =1. $$

For \(x<0\), the random variable cannot take a value at or below \(x\), so \(F_X(x)=0\). For \(0\leq x\leq 3\), integrate from zero:

$$ F_X(x)=\int_0^x \frac{2t}{9}\,dt =\left[\frac{t^2}{9}\right]_0^x =\frac{x^2}{9}. $$

For \(x>3\), all probability has accumulated, so \(F_X(x)=1\). Thus,

$$ F_X(x)= \begin{cases} 0, & x<0,\\ \dfrac{x^2}{9}, & 0\leq x\leq 3,\\ 1, & x>3. \end{cases} $$

At \(x=1.5\), \(F_X(1.5)=(1.5)^2/9=2.25/9=0.25\), or \(0.2500\) to four decimal places. The result is consistent with the formula: it is between zero and one, and the CDF reaches \(3^2/9=1\) at the upper endpoint.

Mistake avoided: using the density value \(f_X(1.5)=3/9\) as the CDF. A density value is not cumulative probability; the CDF requires the integral from the support's lower endpoint.

Worked Example: Carrying Accumulated Probability Across a Breakpoint

In a hypothetical model, a service time \(X\), in hours, has density \(f_X(x)=1/3\) for \(0\leq x<1\), \(f_X(x)=2/3\) for \(1\leq x\leq 2\), and zero otherwise. Construct the CDF and find \(F_X(1.5)\). The model is continuous and has support \([0,2]\).

Method: integrate piece by piece. Check the total area by adding the areas on the two unit-length intervals:

$$ \int_0^1 \frac{1}{3}\,dt+\int_1^2 \frac{2}{3}\,dt =\frac{1}{3}+\frac{2}{3} =1. $$

For \(x<0\), \(F_X(x)=0\). For \(0\leq x<1\), only the first density piece contributes:

$$ F_X(x)=\int_0^x \frac{1}{3}\,dt=\frac{x}{3}. $$

For \(1\leq x\leq 2\), the first interval has already contributed \(1/3\). Add the integral from 1 to \(x\) using the second density:

$$ F_X(x)=\int_0^1\frac{1}{3}\,dt+\int_1^x\frac{2}{3}\,dt =\frac{1}{3}+\frac{2(x-1)}{3} =\frac{2x-1}{3}. $$

For \(x>2\), \(F_X(x)=1\). The resulting CDF is

$$ F_X(x)= \begin{cases} 0, & x<0,\\ \dfrac{x}{3}, & 0\leq x<1,\\ \dfrac{2x-1}{3}, & 1\leq x\leq 2,\\ 1, & x>2. \end{cases} $$

At the breakpoint, the first formula accumulates \(1/3\) by the time \(x=1\), and the next formula also gives \((2(1)-1)/3=1/3\). At \(x=1.5\), \(F_X(1.5)=(3-1)/3=2/3=0.6667\) to four decimal places. At \(x=2\), the formula gives \(1\), agreeing with the total probability.

Mistake avoided: writing only \(\int_1^x (2/3)\,dt\) on the second interval. That would omit the \(1/3\) already accumulated before \(x=1\), producing a CDF that incorrectly resets at the breakpoint.

Worked Example: A Density with a Gap in Its Support

A hypothetical claim payment \(X\), measured in thousands of dollars, has density \(f_X(x)=1/3\) on \(0\leq x\leq 1\), density \(f_X(x)=2/3\) on \(2\leq x\leq 3\), and zero elsewhere. There is no probability in the interval between 1 and 2. Construct the CDF and find \(F_X(2.5)\). The continuous model has support \([0,1]\cup[2,3]\).

Method: accumulate the first supported region, retain its total across the gap, then integrate the next region. The density is valid because

$$ \int_0^1\frac{1}{3}\,dt+\int_2^3\frac{2}{3}\,dt =\frac{1}{3}+\frac{2}{3} =1. $$

Below zero, \(F_X(x)=0\). For \(0\leq x\leq 1\),

$$ F_X(x)=\int_0^x\frac{1}{3}\,dt=\frac{x}{3}. $$

Between 1 and 2, there is no additional density, so the CDF remains at the probability already accumulated, \(1/3\). For \(2\leq x\leq 3\), start with that same accumulated amount and add the area from 2 to \(x\):

$$ F_X(x)=\frac{1}{3}+\int_2^x\frac{2}{3}\,dt =\frac{1}{3}+\frac{2(x-2)}{3} =\frac{2x-3}{3}. $$

Above 3, the CDF is one. Therefore,

$$ F_X(x)= \begin{cases} 0, & x<0,\\ \dfrac{x}{3}, & 0\leq x\leq 1,\\ \dfrac{1}{3}, & 1<x<2,\\ \dfrac{2x-3}{3}, & 2\leq x\leq 3,\\ 1, & x>3. \end{cases} $$

At \(x=2.5\), \(F_X(2.5)=(5-3)/3=2/3=0.6667\) to four decimal places. At the start of the second supported region, the formula gives \(F_X(2)=1/3\); at its end it gives \(F_X(3)=1\). These checks confirm that probability is retained across the gap and that the full density has accumulated by the upper endpoint.

Mistake avoided: setting the CDF back to zero at \(x=2\) because the density was zero in the gap. A zero density means no new probability accumulates there; it does not erase probability accumulated earlier.

Checks and Common Traps

A constructed CDF should agree with the distribution's support and with the total area under its density. These checks often reveal errors before any further probability calculation is attempted.

  • Reverse integration limits. For a CDF, accumulate from the lower support endpoint up to \(x\). Integrating from \(x\) to the upper endpoint instead calculates an upper-tail area, not \(P(X\leq x)\).
  • Drop earlier pieces. On a later interval, add the probability accumulated on all earlier intervals. Do not integrate only the density formula that applies at \(x\).
  • Miss a constant region. If the density is zero over a gap, the CDF stays at its previously accumulated value throughout the gap.
  • Forget the tails. The CDF is zero below the support and one above it. Leaving either part undefined gives an incomplete construction.
  • Fail to check normalization. If the density integrates to a value other than one over its full support, it is not a valid density as stated, and the proposed upper tail of one will not match the integral.

For a piecewise density, a useful final check is to compare the formulas on either side of each breakpoint: the accumulated probability before and after the breakpoint must agree. Also evaluate the expression at the upper end of the support; it must equal one. These checks are not a substitute for integrating correctly, but they help identify missing area and incorrect constants.

Key takeaway: A CDF built from a density is cumulative area. Start at the lower end of the support, integrate up to \(x\), carry all earlier probability through each piece or gap, and use the constant tails zero and one outside the support.

Check Your Understanding

For each continuous model, construct the CDF before evaluating the requested value. Answers are included for checking.

  1. A hypothetical measurement \(X\) has density \(1/4\) on \(2\leq x\leq 6\) and zero elsewhere. Give its CDF and find \(F_X(5)\). (Answer: \(F_X(x)=0\) for \(x<2\), \((x-2)/4\) for \(2\leq x\leq 6\), and \(1\) for \(x>6\); \(F_X(5)=0.7500\).)
  2. A hypothetical severity variable has density \(2x/25\) on \(0\leq x\leq 5\) and zero elsewhere. Find its CDF and \(F_X(4)\). (Answer: \(F_X(x)=0\) for \(x<0\), \(x^2/25\) for \(0\leq x\leq 5\), and \(1\) for \(x>5\); \(F_X(4)=0.6400\).)
  3. A service duration has density \(c\) on \(0\leq x<1\), density \(3c\) on \(1\leq x\leq 2\), and zero elsewhere. Find \(c\), construct the CDF, and evaluate \(F_X(1.5)\). (Answer: \(c=1/4\); the CDF is \(0\) for \(x<0\), \(x/4\) for \(0\leq x<1\), \((3x-2)/4\) for \(1\leq x\leq 2\), and \(1\) for \(x>2\); \(F_X(1.5)=0.6250\).)
  4. A hypothetical cost \(X\) has density \(k(4-x)\) on \(1\leq x\leq 3\) and zero elsewhere. Find \(k\), construct the CDF, and evaluate \(F_X(2)\). (Answer: \(k=1/4\); \(F_X(x)=0\) for \(x<1\), \((4x-x^2/2-7/2)/4\) for \(1\leq x\leq 3\), and \(1\) for \(x>3\); \(F_X(2)=0.6250\).)
Clinical Biostats