Unit 9, lesson 58

Integrals and Probability as Area

How a probability density spreads probability along a scale, how Riemann sums and the definite integral measure the area under it, and how the power rule gives accumulated and interval probabilities.

  • Video 58
  • Integrals and Derivatives for Probability

A computer job finishes at some time between 00 and 11 hour after it starts, and in a constructed model a stretch of later times is more likely than an equally long stretch of earlier times. What is the probability that it finishes in the second half of the hour? A discrete model would list a few possible times and give each one a probability, but here every time in the interval is allowed. So the model spreads probability along the time axis with a curve, and the probability of an interval is the area under the curve over that interval. This lesson builds that area from rectangles, defines the definite integral, and evaluates the integrals of powers that simple densities need.

Key terms

Probability density

Definition A probability density is a function ff defined for every real number xx with two properties. It is nonnegative, f(x)≥0f(x) \ge 0 for every xx, and the total area between its graph and the horizontal axis is 11. The definite integral below makes this area precise, and the total area is written

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

When ff is 00 outside an interval [c,d][c, d], the total area is the area over [c,d][c, d]. If the values of xx carry a unit, such as hours, then ff carries the reciprocal unit, per hour, so that a height times a width is a pure number.

In plain words A density shows how probability is spread along a scale. Its height is probability per unit of width, not a probability. Near a point where the curve is continuous, the height times a short width is approximately the probability of that short interval, so a tall curve over a very narrow interval can still hold very little probability, and a height above 11 breaks no rule.

Example In the constructed job model, the finishing time XX in hours has 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 graph is a triangle with base 11 hour and height 22 per hour, so its area is 12⋅1⋅2=1\tfrac12 \cdot 1 \cdot 2 = 1, and the hours cancel. The height 22 at x=1x = 1 is a rate, not a probability of 22. The clause ”00 otherwise” is part of the model. The formula 2x2x on its own is negative for x<0x < 0 and encloses more and more area as xx grows, so it is not a density.

Probability as area

Definition A random variable XX has density ff when, for all real numbers a≤ba \le b,

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

the area between the graph of ff and the horizontal axis over [a,b][a, b]. Taking a=ba = b gives an interval of width 00 and area 00, so P(X=a)=0P(X = a) = 0 for every aa. Hence including or excluding an endpoint does not change the probability, and P(a<X<b)P(a < X < b), P(a<X≤b)P(a < X \le b) and P(a≤X<b)P(a \le X < b) equal the same area.

In plain words In a density model, probability lives in areas over intervals. To find the probability of an event about XX, shade the part of the horizontal axis that the event describes and measure the area under the curve above it.

Example For the job model, the probability of finishing in the second half of the hour is the area over [12,1][\tfrac12, 1]. That region is a trapezoid with width 12\tfrac12 and parallel sides f(12)=1f(\tfrac12) = 1 and f(1)=2f(1) = 2, so

P(12≤X≤1)=12⋅1+22=34.\begin{aligned} P\left(\tfrac12 \le X \le 1\right) &= \tfrac12 \cdot \frac{1 + 2}{2} \\[0.4em] &= \tfrac34. \end{aligned}

The first half of the hour is a triangle with base 12\tfrac12 and height 11, so it has probability 14\tfrac14. The two halves have the same width but different probabilities, because the curve is higher over the second half.

Riemann sum

Definition Let ff be a function on an interval [a,b][a, b] with a<ba < b. Split [a,b][a, b] into nn pieces with endpoints a=x0<x1<⋯<xn=ba = x_0 < x_1 < \dots < x_n = b, choose a point xi∗x_i^{*} in each piece [xi−1,xi][x_{i-1}, x_i], and write Δxi=xi−xi−1\Delta x_i = x_i - x_{i-1} for its width. The number

∑i=1nf(xi∗) Δxi\sum_{i=1}^{n} f(x_i^{*})\,\Delta x_i

is a Riemann sum for ff on [a,b][a, b]. With nn equal widths Δx=(b−a)/n\Delta x = (b - a)/n, choosing every left endpoint gives the left sum LnL_n, and choosing every right endpoint gives the right sum RnR_n. When ff is nonnegative, each term is the area of a rectangle. When ff is also nondecreasing on [a,b][a, b], every rectangle of a left sum lies under the graph and every rectangle of a right sum covers the region beneath the graph on its piece, so the left sum is at most the area and the right sum is at least the area.

In plain words Replace the curved region by a row of rectangles, each as wide as its piece and as tall as the curve at the chosen point. The rectangles may miss some area or include some extra, so a Riemann sum estimates an area. For a density, a Riemann sum is only an estimate of a probability, and it can even exceed 11.

Example For the density 2x2x on [0,1][0, 1], split into four pieces of width 14\tfrac14. The left endpoints give the heights 00, 12\tfrac12, 11 and 32\tfrac32, which add to 33, and the right endpoints give 12\tfrac12, 11, 32\tfrac32 and 22, which add to 55. So

L4=14⋅3=34,R4=14⋅5=54.\begin{aligned} L_4 &= \tfrac14 \cdot 3 = \tfrac34, \\[0.4em] R_4 &= \tfrac14 \cdot 5 = \tfrac54. \end{aligned}

The true area 11 lies between these bounds. The value 54\tfrac54 is not a probability of the model. It only shows that the right rectangles overshoot. With nn equal pieces the same computation gives Ln=1−1nL_n = 1 - \tfrac1n and Rn=1+1nR_n = 1 + \tfrac1n, for example 0.990.99 and 1.011.01 when n=100n = 100.

Definite integral

Definition Let ff be a function on [a,b][a, b] with a<ba < b. Suppose the Riemann sums of ff approach a single number II as the widest piece shrinks to width 00, whatever points xi∗x_i^{*} are chosen. Then ff is integrable on [a,b][a, b], and II is its definite integral,

∫abf(x) dx=I.\int_a^b f(x)\,dx = I.

The limit exists, for example, when ff is continuous on [a,b][a, b], and also when ff is bounded with finitely many jumps. The numbers aa and bb are the lower and upper limits of integration, f(x)f(x) is the integrand, and dxdx names the variable that runs from aa to bb. The letter used for that variable does not matter, so ∫abf(t) dt\int_a^b f(t)\,dt is the same number. By convention the integral from aa to aa is 00. For a nonnegative ff the integral is the area under the graph over [a,b][a, b]. When ff is integrable on [a,c][a, c] and a<b<ca < b < c, integrals over adjacent intervals add,

∫acf(x) dx=∫abf(x) dx+∫bcf(x) dx.\begin{aligned} \int_a^c f(x)\,dx &= \int_a^b f(x)\,dx \\[0.4em] &\quad + \int_b^c f(x)\,dx. \end{aligned}

In plain words The integral is the value the rectangle sums settle on as the rectangles get narrower. The limits of integration say where to start and stop collecting area, and the integrand says how tall the curve is along the way. The elongated S of the integral sign is a reminder that it comes from a sum.

Example The density 2x2x is continuous on [0,1][0, 1], so its integral exists. Because 2x2x is increasing, every Riemann sum with nn equal pieces lies between Ln=1−1nL_n = 1 - \tfrac1n and Rn=1+1nR_n = 1 + \tfrac1n, and both bounds approach 11. Hence

∫012x dx=1,\int_0^1 2x\,dx = 1,

which agrees with the triangle. The event X>12X > \tfrac12 has no upper end, but the density is 00 above 11, so the limits of integration are 12\tfrac12 and 11. Continuing the formula 2x2x past 11 would count area that the model does not have.

Accumulated probability

Definition For a random variable XX with density ff, the accumulated probability up to a real number xx 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}

which is the cumulative distribution function of XX evaluated at xx. When ff is 00 below cc, this gives F(x)=0F(x) = 0 for x<cx < c, and for x≥cx \ge c the integral can start at cc. The moving endpoint xx is the upper limit, so the variable of integration gets a different letter. For real numbers a<ba < b, subtracting accumulated probabilities gives the probability of the interval between them,

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

In plain words Sweep a vertical line from left to right and record how much area lies to its left. The probability of an interval is the amount the sweep adds between the two endpoints.

Example For the job model and 0≤x≤10 \le x \le 1, the region to the left of xx is a triangle with base xx and height 2x2x, so

F(x)=∫0x2t dt=12⋅x⋅2x=x2.\begin{aligned} F(x) &= \int_0^x 2t\,dt \\[0.4em] &= \tfrac12 \cdot x \cdot 2x = x^2. \end{aligned}

Also F(x)=0F(x) = 0 for x<0x < 0 and F(x)=1F(x) = 1 for x>1x > 1. Halfway through the hour the accumulated probability is F(12)=14F(\tfrac12) = \tfrac14, not 12\tfrac12. The middle half-hour has probability

P(14<X≤34)=F(34)−F(14)=916−116=12,\begin{aligned} &P\left(\tfrac14 < X \le \tfrac34\right) \\[0.4em] &\quad = F\left(\tfrac34\right) - F\left(\tfrac14\right) \\[0.4em] &\quad = \tfrac{9}{16} - \tfrac{1}{16} = \tfrac12, \end{aligned}

and the second half-hour has probability 1−14=341 - \tfrac14 = \tfrac34, which answers the opening question. The first, middle and last half-hours have the same width but probabilities 14\tfrac14, 12\tfrac12 and 34\tfrac34.

Power rule for integrals

Definition For every nonnegative integer kk and real numbers a≤ba \le b,

∫abxk dx=bk+1−ak+1k+1,\int_a^b x^k\,dx = \frac{b^{k+1} - a^{k+1}}{k+1},

where x0x^0 means 11, so the case k=0k = 0 gives b−ab - a. For integrable functions ff and gg and a constant cc, integrals respect constant multiples and sums,

∫abcf(x) dx=c∫abf(x) dx,∫ab(f(x)+g(x)) dx=∫abf(x) dx+∫abg(x) dx.\begin{gathered} \int_a^b c f(x)\,dx = c \int_a^b f(x)\,dx, \\[0.4em] \int_a^b \bigl(f(x) + g(x)\bigr)\,dx \\[0.4em] = \int_a^b f(x)\,dx + \int_a^b g(x)\,dx. \end{gathered}

Together these rules integrate every polynomial over every interval [a,b][a, b].

In plain words To integrate a whole-number power of xx, raise the power by one, divide by the new power, and subtract the value at the lower limit from the value at the upper limit. A constant factor scales every strip of area, so it scales the total.

Example The constructed density f(x)=6x−6x2f(x) = 6x - 6x^2 for 0≤x≤10 \le x \le 1, and 00 otherwise, is nonnegative because 6x(1−x)≥06x(1 - x) \ge 0 on [0,1][0, 1]. Its total area is

∫01(6x−6x2) dx=6⋅12−6⋅13=3−2=1,\begin{aligned} &\int_0^1 (6x - 6x^2)\,dx \\[0.4em] &\quad = 6 \cdot \tfrac12 - 6 \cdot \tfrac13 \\[0.4em] &\quad = 3 - 2 = 1, \end{aligned}

so it is a valid density, even though its peak height is f(12)=32f(\tfrac12) = \tfrac32. The probability of a value below 14\tfrac14 is

∫01/4(6x−6x2) dx=3(14)2−2(14)3=316−132=532.\begin{aligned} &\int_0^{1/4} (6x - 6x^2)\,dx \\[0.4em] &\quad = 3\left(\tfrac14\right)^2 - 2\left(\tfrac14\right)^3 \\[0.4em] &\quad = \tfrac{3}{16} - \tfrac{1}{32} = \tfrac{5}{32}. \end{aligned}

Check yourself

  1. A quantity XX has density f(x)=3x2f(x) = 3x^2 for 0≤x≤10 \le x \le 1 and f(x)=0f(x) = 0 otherwise. Check that ff is a valid density, find the accumulated probability F(x)F(x) for 0≤x≤10 \le x \le 1, and find P(X>12)P(X > \tfrac12).
Show the answer

The function is nonnegative because x2≥0x^2 \ge 0, and by the power rule its total area is

∫013x2 dx=3⋅13−033=1,\int_0^1 3x^2\,dx = 3 \cdot \frac{1^3 - 0^3}{3} = 1,

so it is a valid density. For 0≤x≤10 \le x \le 1 the accumulated probability is F(x)=∫0x3t2 dt=x3F(x) = \int_0^x 3t^2\,dt = x^3. By the complement rule,

P(X>12)=1−F(12)=1−18=78.\begin{aligned} P\left(X > \tfrac12\right) &= 1 - F\left(\tfrac12\right) \\[0.4em] &= 1 - \tfrac18 = \tfrac78. \end{aligned}
  1. For the same XX, find P(12<X<34)P(\tfrac12 < X < \tfrac34) and check that the answer is reasonable.
Show the answer

Subtract accumulated probabilities,

P(12<X<34)=F(34)−F(12)=2764−864=1964.\begin{aligned} &P\left(\tfrac12 < X < \tfrac34\right) \\[0.4em] &\quad = F\left(\tfrac34\right) - F\left(\tfrac12\right) \\[0.4em] &\quad = \tfrac{27}{64} - \tfrac{8}{64} = \tfrac{19}{64}. \end{aligned}

The endpoints have probability 00, so it does not matter that they are excluded. The answer, about 0.2970.297, lies between 00 and 78\tfrac78, as it must, because the event is part of the event X>12X > \tfrac12. A negative result would point to a reversed subtraction.

  1. A classmate computes the right Riemann sum with four equal pieces for the density 3x23x^2 on [0,1][0, 1] and gets 4532\tfrac{45}{32}, which is more than 11. The classmate also notices that the density reaches the height 33 at x=1x = 1. Does either fact show that ff is not a valid density?
Show the answer

Neither does. The right heights are 316\tfrac{3}{16}, 34\tfrac34, 2716\tfrac{27}{16} and 33, which add to 458\tfrac{45}{8}, so R4=14⋅458=4532R_4 = \tfrac14 \cdot \tfrac{45}{8} = \tfrac{45}{32} is computed correctly. Because 3x23x^2 is increasing on [0,1][0, 1], each right rectangle uses the tallest height on its piece, so R4R_4 overestimates the area. The left sum is L4=14(0+316+34+2716)=2132L_4 = \tfrac14(0 + \tfrac{3}{16} + \tfrac34 + \tfrac{27}{16}) = \tfrac{21}{32}, an underestimate, and the exact area 11 lies between the two.

The height 33 is probability per unit of xx. Just below x=1x = 1, a short interval of width 0.010.01 has probability close to 3⋅0.01=0.033 \cdot 0.01 = 0.03, and indeed P(0.99<X≤1)=1−0.993≈0.0297P(0.99 < X \le 1) = 1 - 0.99^3 \approx 0.0297.

How this lesson connects

It also uses areas of rectangles and triangles and an informal idea of a limit.