Unit 9, lesson 60

Probability Densities and CDFs

What makes a function a probability density, why density heights carry units and can exceed 1, how to write the complete CDF of an absolutely continuous variable, and why each single value has probability zero.

  • Video 60
  • Densities and Mixed Distributions

A constructed model for a waiting time, measured in hours, uses a density curve that reaches the height 22. Does that give some waiting time a probability of 22, which no probability can be? It does not, because a density height is not a probability at all. Keeping three things apart settles the question, namely the possible values, the density at those values, and the probability of an interval. This lesson states exactly what a density must satisfy, what its height and units mean, how to write a complete CDF and read interval probabilities from it, and why each single value has probability zero.

Key terms

Probability density function

Definition A probability density function, or density, is a function ff defined for every real number xx with f(x)≥0f(x) \ge 0 for every xx and

∫−∞∞f(x) dx=1.\int_{-\infty}^{\infty} f(x)\,dx = 1.

A random variable XX has density ff if, for all real numbers a<ba < b,

P(a<X≤b)=∫abf(x) dx.\begin{aligned} &P(a < X \le b) \\[0.4em] &\quad = \int_a^b f(x)\,dx. \end{aligned}

The distribution of XX is then called absolutely continuous. Every absolutely continuous distribution has a continuous CDF, but a continuous CDF alone does not guarantee a density. In the models of this lesson, the probability is spread over an interval, called the support, and ff is 00 outside it. A density of a distribution is not unique, since changing ff at finitely many points, to other nonnegative values, changes no integral and so gives another density of the same distribution.

In plain words A density describes a distribution by how thickly probability is spread along the axis. The probability of an interval is the area under the curve above it, and the heights of the curve are rates, not probabilities.

Example Let the waiting time XX, in hours, have density

f(x)={2x,0≤x≤1,0,otherwise.f(x) = \begin{cases} 2x, & 0 \le x \le 1, \\ 0, & \text{otherwise}. \end{cases}

The support is [0,1][0, 1], the function is nonnegative, and the region under it is a triangle with base 11 and height 22, so its area is 11. Writing only f(x)=2xf(x) = 2x would not define a distribution, because that formula is negative for every x<0x < 0.

Normalization of a density

Definition A function ff is a density exactly when it passes two separate checks. It must be nonnegative, f(x)≥0f(x) \ge 0 for every xx, and it must be normalized, with total integral 11. If gg is a nonnegative function whose total area AA is finite and positive, then f=g/Af = g/A is a density, and finding this ff is called normalizing gg. In particular, a density of the form cg(x)cg(x) requires c=1/Ac = 1/A.

In plain words The total probability must be 11, so the heights of a density are scaled to fit the width of its support. Spreading the same total over a wider interval calls for a lower average height.

Example Suppose f(x)=cxf(x) = cx for 0≤x≤20 \le x \le 2 and f(x)=0f(x) = 0 otherwise. Normalization requires

∫02cx dx=c⋅222=2c=1,\int_0^2 cx\,dx = c \cdot \frac{2^2}{2} = 2c = 1,

so c=12c = \tfrac12 and f(x)=x/2f(x) = x/2 on [0,2][0, 2], which is nonnegative. The constant height 22 on [0,2][0, 2] is nonnegative but encloses area 44, so it is not a density, while the constant height 12\tfrac12 on [0,2][0, 2] is one. In the other direction, 4x−14x - 1 on [0,1][0, 1] has total area 2−1=12 - 1 = 1 but is negative for 0≤x<140 \le x < \tfrac14, and it would give the interval [0,14][0, \tfrac14] the impossible value

∫01/4(4x−1) dx=−18.\int_0^{1/4} (4x - 1)\,dx = -\tfrac18.

Density units

Definition If XX is measured in some unit, then a density value f(x)f(x) is measured in probability per unit of XX, the reciprocal unit, such as per hour. A probability comes from a density only as an area, where heights are multiplied by widths and added up. A density value can be any nonnegative number, including numbers larger than 11. If the variable is rescaled to Y=cXY = cX with a constant c>0c > 0, as in a change of units, then P(Y≤y)=P(X≤y/c)P(Y \le y) = P(X \le y/c), and the substitution x=t/cx = t/c in the integral of fXf_X up to y/cy/c shows that YY has density

fY(y)=1c fX ⁣(yc).f_Y(y) = \frac{1}{c}\, f_X\!\left(\frac{y}{c}\right).

In plain words A density height says how much probability there is per unit of width. Measuring the same quantity in a smaller unit spreads the same probability over more units, so every height is divided by the conversion factor, while every probability stays the same.

Example For the waiting time XX with density 2x2x on [0,1][0, 1], the height at 11 hour is 22 per hour. The same wait in minutes is M=60XM = 60X, with density

fM(m)=160⋅2⋅m60=m1800\begin{aligned} f_M(m) &= \frac{1}{60} \cdot 2 \cdot \frac{m}{60} \\[0.4em] &= \frac{m}{1800} \end{aligned}

for 0≤m≤600 \le m \le 60, so the height at 6060 minutes is 130\tfrac{1}{30} per minute. The event of waiting at most half an hour has the same probability in both units, P(X≤12)=14P(X \le \tfrac12) = \tfrac14 and P(M≤30)=302/3600=14P(M \le 30) = 30^2/3600 = \tfrac14. In the same way, the density x/2x/2 on [0,2][0, 2] from the previous card is the density of 2X2X.

CDF of a continuous variable

Definition If XX has density ff, its CDF is

F(x)=P(X≤x)=∫−∞xf(t) dt\begin{aligned} F(x) &= P(X \le x) \\[0.4em] &= \int_{-\infty}^{x} f(t)\,dt \end{aligned}

for every real number xx. This FF is continuous everywhere and nondecreasing, it tends to 00 as x→−∞x \to -\infty and to 11 as x→∞x \to \infty, and F′(x)=f(x)F'(x) = f(x) at every xx where ff is continuous. A complete CDF gives a value at every real threshold. For a density that is 00 outside [c,d][c, d], it equals 00 for x<cx < c, equals ∫cxf(t) dt\int_c^x f(t)\,dt for c≤x≤dc \le x \le d, and equals 11 for x>dx > d.

In plain words The CDF records the area to the left of each threshold. It is flat on every interval where the density is 00, rises over every interval where the density is positive, and never exceeds 11. The horizontal pieces outside the support are part of the answer, not decoration.

Example For the density 2x2x on [0,1][0, 1], integrating from 00 to xx gives x2x^2, so

F(x)={0,x<0,x2,0≤x≤1,1,x>1.F(x) = \begin{cases} 0, & x < 0, \\ x^2, & 0 \le x \le 1, \\ 1, & x > 1. \end{cases}

The formula x2x^2 on its own is not the CDF, since it exceeds 11 for x>1x > 1 and decreases for x<0x < 0, which no CDF can do. The pieces meet at 00 and at 11, so FF has no jumps. For the density x/2x/2 on [0,2][0, 2], the middle piece is x2/4x^2/4 for 0≤x≤20 \le x \le 2, with 00 to its left and 11 to its right.

Interval probability from a CDF

Definition For any random variable XX with CDF FF and real numbers a<ba < b,

P(a<X≤b)=F(b)−F(a),P(X>a)=1−F(a).\begin{aligned} P(a < X \le b) &= F(b) - F(a), \\[0.4em] P(X > a) &= 1 - F(a). \end{aligned}

When XX has a density, FF is continuous, so including or excluding endpoints changes nothing. The probabilities P(a≤X≤b)P(a \le X \le b), P(a<X<b)P(a < X < b) and P(a≤X<b)P(a \le X < b) also equal F(b)−F(a)F(b) - F(a), and P(X≥a)=1−F(a)P(X \ge a) = 1 - F(a).

In plain words Take the probability accumulated up to the right end and remove what had accumulated by the left end. For an upper tail, remove the accumulated probability from the total 11.

Example For the density 2x2x on [0,1][0, 1],

P(0.2<X<0.8)=F(0.8)−F(0.2)=0.64−0.04=0.6,\begin{aligned} &P(0.2 < X < 0.8) \\[0.4em] &\quad = F(0.8) - F(0.2) \\[0.4em] &\quad = 0.64 - 0.04 = 0.6, \end{aligned}

and P(X>0.8)=1−0.64=0.36P(X > 0.8) = 1 - 0.64 = 0.36. For the density x/2x/2 on [0,2][0, 2], the probability of a value above 11 is 1−F(1)=1−14=341 - F(1) = 1 - \tfrac14 = \tfrac34.

Zero probability at a point

Definition If XX has a density, then P(X=c)=0P(X = c) = 0 for every real number cc. Indeed, for every h>0h > 0,

P(X=c)≤P(c−h<X≤c)=F(c)−F(c−h),\begin{aligned} &P(X = c) \\[0.4em] &\quad \le P(c - h < X \le c) \\[0.4em] &\quad = F(c) - F(c - h), \end{aligned}

and the right side tends to 00 as hh decreases to 00, because FF is continuous. Probability 00 does not mean impossible. Every value of XX has probability 00, yet XX always takes some value. A random variable that gives some single value positive probability, such as any discrete random variable, has no density.

In plain words In a density model, probability lives on intervals, not on single points. Shrinking an interval around a point shrinks its area to 00, even where the curve is tall.

Example For the density 2x2x on [0,1][0, 1],

P(0.8−h<X≤0.8)=0.64−(0.8−h)2=1.6h−h2,\begin{aligned} &P(0.8 - h < X \le 0.8) \\[0.4em] &\quad = 0.64 - (0.8 - h)^2 \\[0.4em] &\quad = 1.6h - h^2, \end{aligned}

which is 0.01590.0159 for h=0.01h = 0.01 and tends to 00. So P(X=0.8)=0P(X = 0.8) = 0, even though 0.80.8 lies inside the support and f(0.8)=1.6f(0.8) = 1.6. This is why P(0.2≤X≤0.8)P(0.2 \le X \le 0.8) is also 0.60.6. A fair die roll DD is different. It has P(D=3)=16P(D = 3) = \tfrac16, a jump of 16\tfrac16 in its CDF at 33, and no density.

Check yourself

  1. A random variable XX has density f(x)=13f(x) = \tfrac13 for 0≤x≤10 \le x \le 1, f(x)=23f(x) = \tfrac23 for 1<x≤21 < x \le 2, and f(x)=0f(x) = 0 otherwise. Check that ff is a density, and find P(0.5<X<1.5)P(0.5 < X < 1.5) from areas.
Show the answer

Both heights are nonnegative, and the two rectangles have areas 1⋅131 \cdot \tfrac13 and 1⋅231 \cdot \tfrac23, which add to 11. The interval (0.5,1.5)(0.5, 1.5) covers half of each rectangle, so

P(0.5<X<1.5)=0.5⋅13+0.5⋅23=16+13=12.\begin{aligned} &P(0.5 < X < 1.5) \\[0.4em] &\quad = 0.5 \cdot \tfrac13 + 0.5 \cdot \tfrac23 \\[0.4em] &\quad = \tfrac16 + \tfrac13 = \tfrac12. \end{aligned}
  1. Write the complete CDF of the same XX, and use it to check the answer to question 1.
Show the answer

Below 00 nothing has accumulated. On [0,1][0, 1] the area is x/3x/3. Beyond 11 the first rectangle contributes 13\tfrac13 and the second adds 23(x−1)\tfrac23(x - 1), which together give (2x−1)/3(2x - 1)/3. So

F(x)={0,x<0,x3,0≤x<1,2x−13,1≤x<2,1,x≥2.F(x) = \begin{cases} 0, & x < 0, \\ \frac{x}{3}, & 0 \le x < 1, \\ \frac{2x - 1}{3}, & 1 \le x < 2, \\ 1, & x \ge 2. \end{cases}

The piece x/3x/3 is 00 at x=0x = 0, both middle pieces give 13\tfrac13 at x=1x = 1, and the second of them gives 11 at x=2x = 2, so FF is continuous even though the density jumps at 00, 11 and 22. Then F(1.5)−F(0.5)=23−16=12F(1.5) - F(0.5) = \tfrac23 - \tfrac16 = \tfrac12, which matches.

  1. A random variable XX has density f(x)=c(2−x)f(x) = c(2 - x) for 0≤x≤20 \le x \le 2 and f(x)=0f(x) = 0 otherwise. Find cc, then find P(X≤1)P(X \le 1) and P(X=1)P(X = 1). A classmate answers P(X=1)=f(1)P(X = 1) = f(1). What is wrong with that?
Show the answer

Normalization requires

∫02c(2−x) dx=c(4−2)=2c=1,\begin{aligned} \int_0^2 c(2 - x)\,dx &= c(4 - 2) \\[0.4em] &= 2c = 1, \end{aligned}

so c=12c = \tfrac12, and then f(x)=1−x/2f(x) = 1 - x/2 is nonnegative on [0,2][0, 2]. The CDF on [0,2][0, 2] is F(x)=x−x2/4F(x) = x - x^2/4, so P(X≤1)=1−14=34P(X \le 1) = 1 - \tfrac14 = \tfrac34. Because XX has a density, P(X=1)=0P(X = 1) = 0. The classmate’s value f(1)=12f(1) = \tfrac12 is a probability per unit of xx, not a probability. It says that a short interval of width hh near 11 has probability close to 12h\tfrac12 h.

How this lesson connects