Unit 9, lesson 59

Derivatives and the Density-CDF Connection

How difference quotients and derivatives measure local change, how the fundamental theorem of calculus ties integrals to antiderivatives, and when differentiating a CDF gives back its density.

  • Video 59
  • Integrals and Derivatives for Probability

Suppose a random variable XX between 00 and 11 is described by its cumulative distribution function, F(x)=x2F(x) = x^2 for 0≤x≤10 \le x \le 1, and no density is given. The CDF says how much probability has accumulated up to each threshold. How densely is probability packed near the threshold 0.40.4? That is a question about how fast the accumulated probability grows there, and rates of change are measured by derivatives. This lesson defines the derivative as a limit of difference quotients, links it to integration through the fundamental theorem of calculus, and shows when differentiating a CDF recovers a density and when it cannot.

Key terms

Difference quotient

Definition Let FF be a function defined at xx and at x+hx + h, where h≠0h \ne 0. The difference quotient of FF at xx with step hh is

F(x+h)−F(x)h.\frac{F(x + h) - F(x)}{h}.

It is the slope of the secant line through the points (x,F(x))(x, F(x)) and (x+h,F(x+h))(x + h, F(x + h)) on the graph of FF. When FF is the CDF of a random variable XX and h>0h > 0, the numerator is P(x<X≤x+h)P(x < X \le x + h), so the quotient is the average probability per unit of xx over the interval (x,x+h](x, x + h].

In plain words Move the threshold by a small step, see how much the function changes, and divide that change by the step, counting a step to the left as negative. For a CDF, the result is the probability of the short interval between the two thresholds per unit of width.

Example Let XX have the CDF

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}

When xx and x+hx + h both lie in [0,1][0, 1], the squared terms cancel,

F(x+h)−F(x)h=(x+h)2−x2h=2xh+h2h=2x+h.\begin{aligned} &\frac{F(x + h) - F(x)}{h} \\[0.4em] &\quad = \frac{(x + h)^2 - x^2}{h} \\[0.4em] &\quad = \frac{2xh + h^2}{h} = 2x + h. \end{aligned}

At x=0.4x = 0.4 the quotient is 0.8+h0.8 + h. For h=0.1h = 0.1 the numerator is P(0.4<X≤0.5)=0.25−0.16=0.09P(0.4 < X \le 0.5) = 0.25 - 0.16 = 0.09, and dividing by the width 0.10.1 gives 0.90.9.

Step hhDifference quotient at 0.40.4
0.10.10.90.9
0.010.010.810.81
0.0010.0010.8010.801
−0.001-0.0010.7990.799
−0.01-0.010.790.79
−0.1-0.10.70.7

Derivative

Definition Let FF be defined on an open interval containing xx. If the difference quotients approach a limit as h→0h \to 0 through nonzero values of both signs, then FF is differentiable at xx, and the limit

F′(x)=lim⁡h→0F(x+h)−F(x)h\begin{aligned} &F'(x) \\[0.4em] &\quad = \lim_{h \to 0} \frac{F(x + h) - F(x)}{h} \end{aligned}

is the derivative of FF at xx. The line through (x,F(x))(x, F(x)) with slope F′(x)F'(x) is the tangent line, and F′(x)F'(x) is the tangent slope. If the limit does not exist, FF has no derivative and no tangent slope at xx. The derivative is measured in units of FF per unit of xx.

In plain words The derivative is the slope that the secant lines settle on as the second point slides toward the first from either side. It measures how fast FF changes at the point itself, not over a stretch.

Example For the CDF above, the quotients at 0.40.4 equal 0.8+h0.8 + h, which tends to 0.80.8 from both sides, so F′(0.4)=0.8F'(0.4) = 0.8. The tangent line at (0.4,0.16)(0.4, 0.16) has slope 0.80.8, and if xx is measured in hours the derivative is 0.80.8 per hour. The same computation gives F′(x)=2xF'(x) = 2x for every xx with 0<x<10 < x < 1. At x=1x = 1 there is no derivative. For h<0h < 0 the quotient is 2+h2 + h, which tends to 22, while for h>0h > 0 it is (1−1)/h=0(1 - 1)/h = 0. The graph has a corner there, with slope 22 on the left and slope 00 on the right.

Power rule for derivatives

Definition For every positive integer nn, the function xnx^n is differentiable at every real xx, and

ddx xn=nxn−1,\frac{d}{dx}\, x^n = n x^{n-1},

where x0x^0 means 11, so the derivative of xx is 11. A constant function has derivative 00 everywhere. Derivatives respect constant multiples and sums, so (cF)′(x)=cF′(x)(cF)'(x) = cF'(x) and (F+G)′(x)=F′(x)+G′(x)(F + G)'(x) = F'(x) + G'(x) at every xx where FF and GG are differentiable. Together these rules differentiate every polynomial.

In plain words Bring the exponent down as a factor and lower the exponent by one. A constant does not change, so its rate of change is zero.

Example For n=3n = 3, expanding (x+h)3=x3+3x2h+3xh2+h3(x + h)^3 = x^3 + 3x^2h + 3xh^2 + h^3 gives

(x+h)3−x3h=3x2+3xh+h2,\begin{aligned} &\frac{(x + h)^3 - x^3}{h} \\[0.4em] &\quad = 3x^2 + 3xh + h^2, \end{aligned}

which tends to 3x23x^2 as h→0h \to 0. So the derivative of x3x^3 is 3x23x^2, and adding a constant does not change it, since x3+2x^3 + 2 also has derivative 3x23x^2. With the multiple and sum rules, the polynomial 3x2−2x33x^2 - 2x^3 has derivative 6x−6x26x - 6x^2.

Fundamental theorem of calculus

Definition Let ff be continuous on [a,b][a, b] with a<ba < b. The theorem has two parts.

The first part says that the accumulated area G(x)=∫axf(t) dtG(x) = \int_a^x f(t)\,dt, defined for a≤x≤ba \le x \le b, is differentiable at every xx with a<x<ba < x < b, and G′(x)=f(x)G'(x) = f(x). If ff is only integrable on [a,b][a, b], for example bounded with finitely many jumps, the conclusion G′(x)=f(x)G'(x) = f(x) still holds at each xx with a<x<ba < x < b where ff is continuous.

The second part says that if GG is continuous on [a,b][a, b] and G′(x)=f(x)G'(x) = f(x) for every xx with a<x<ba < x < b, then

∫abf(x) dx=G(b)−G(a).\int_a^b f(x)\,dx = G(b) - G(a).

In plain words Differentiating accumulated area gives back the height of the curve wherever the curve is continuous. In the other direction, to integrate a continuous function over an interval it is enough to know any function whose rate of change equals the integrand throughout that interval, and to subtract its values at the two limits.

Example For f(t)=2tf(t) = 2t on [0,1][0, 1], the accumulated area is ∫0x2t dt=x2\int_0^x 2t\,dt = x^2, and its derivative 2x2x is the height f(x)f(x), as the first part says. For the second part, take the continuous integrand 6x−6x26x - 6x^2 on [0,1][0, 1]. The power rule shows that G(x)=3x2−2x3G(x) = 3x^2 - 2x^3 has derivative 6x−6x26x - 6x^2, so

∫01/2(6x−6x2) dx=G(12)−G(0)=(34−14)−0=12.\begin{aligned} &\int_0^{1/2} (6x - 6x^2)\,dx \\[0.4em] &\quad = G\left(\tfrac12\right) - G(0) \\[0.4em] &\quad = \left(\tfrac34 - \tfrac14\right) - 0 = \tfrac12. \end{aligned}

Antiderivative

Definition Let ff be a function on an open interval II. A function GG is an antiderivative of ff on II if G′(x)=f(x)G'(x) = f(x) for every xx in II. If GG is one antiderivative of ff on II, then the antiderivatives of ff on II are exactly the functions G+CG + C with CC a constant. In the second part of the fundamental theorem the constant cancels, because

(G(b)+C)−(G(a)+C)=G(b)−G(a).\begin{aligned} &\bigl(G(b) + C\bigr) - \bigl(G(a) + C\bigr) \\[0.4em] &\quad = G(b) - G(a). \end{aligned}

In plain words An antiderivative undoes differentiation. Functions with the same rate of change on an interval differ only by a vertical shift, and the shift drops out when you subtract values at two limits.

Example On the whole real line, x3x^3 and x3+2x^3 + 2 are both antiderivatives of 3x23x^2. Either one gives

∫01/23x2 dx=18,\int_0^{1/2} 3x^2\,dx = \tfrac18,

since (18+2)−(0+2)=18\bigl(\tfrac18 + 2\bigr) - (0 + 2) = \tfrac18. They are not equally good as CDFs, though. For a density ff that is continuous on [c,d][c, d] and 00 outside it, the CDF on [c,d][c, d] is ∫cxf(t) dt\int_c^x f(t)\,dt, the antiderivative that starts at 00 at cc. For the density 3x23x^2 on [0,1][0, 1] that is x3x^3, while x3+2x^3 + 2 starts at 22 and is no CDF at all.

Density as the derivative of the CDF

Definition Let XX have density ff and CDF FF, so that F(x)=∫−∞xf(t) dtF(x) = \int_{-\infty}^{x} f(t)\,dt for every real xx. By the fundamental theorem, F′(x)=f(x)F'(x) = f(x) at every xx where ff is continuous. In the other direction, suppose the CDF FF of a random variable XX is continuous everywhere, and that outside a finite set of points FF is differentiable with a continuous derivative. Then setting f(x)=F′(x)f(x) = F'(x) outside that set, and choosing any nonnegative values at its points, gives a density of XX. Changing a density at finitely many points changes no integral, so all such choices give the same probabilities. If FF jumps at cc, then P(X=c)>0P(X = c) > 0, and XX has no density at all, because a density gives every single value probability 00. Continuity alone is not enough either. The Cantor function is a continuous CDF that rises from 00 to 11 on [0,1][0, 1], yet it is constant on intervals of total length 11. Its derivative is 00 on all of those intervals, the remaining points have total length 00, and no density produces this CDF.

In plain words When a variable has a density, the slope of its CDF at each point where the CDF is smooth is the density there, the local rate at which probability accumulates. A density value is not the probability of a point. Near a point xx where ff is continuous, a short interval of width hh has probability close to f(x)hf(x)h. Differentiation cannot see probability that sits on a single value, because that probability shows up as a jump, not as a slope.

Example For the CDF F(x)=x2F(x) = x^2 on [0,1][0, 1], the derivative is 2x2x for 0<x<10 < x < 1 and 00 for x<0x < 0 and x>1x > 1. At 00 both one-sided slopes are 00, so F′(0)=0F'(0) = 0, and at the corner x=1x = 1 there is no derivative. So f(x)=2xf(x) = 2x for 0≤x≤10 \le x \le 1 and f(x)=0f(x) = 0 otherwise is a density of XX, and setting f(1)=0f(1) = 0 instead would change no probability. The value F′(0.4)=0.8F'(0.4) = 0.8 is not P(X=0.4)P(X = 0.4), which is 00. It says that

P(0.4<X≤0.41)=0.412−0.42=0.0081\begin{aligned} &P(0.4 < X \le 0.41) \\[0.4em] &\quad = 0.41^2 - 0.4^2 = 0.0081 \end{aligned}

is close to 0.8⋅0.01=0.0080.8 \cdot 0.01 = 0.008.

Check yourself

  1. A random variable XX has CDF F(x)=0F(x) = 0 for x<0x < 0, F(x)=x3F(x) = x^3 for 0≤x≤10 \le x \le 1 and F(x)=1F(x) = 1 for x>1x > 1. Find a density of XX. Where does FF fail to have a derivative, and does that matter?
Show the answer

By the power rule, F′(x)=3x2F'(x) = 3x^2 for 0<x<10 < x < 1, and F′(x)=0F'(x) = 0 for x<0x < 0 and for x>1x > 1, where FF is constant. At x=0x = 0 both one-sided slopes are 00, so F′(0)=0F'(0) = 0. At x=1x = 1 the quotients from the left are 3+3h+h23 + 3h + h^2, which tend to 33, while those from the right are 00, so FF has a corner and no derivative there. A density is

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

and its total area is 13−03=11^3 - 0^3 = 1. The missing derivative at the single point 11 does not matter, because any nonnegative value of f(1)f(1) gives the same integrals and so the same probabilities.

  1. For the same XX, find P(14<X<12)P(\tfrac14 < X < \tfrac12) in two ways, from the CDF and by integrating the density.
Show the answer

From the CDF, F(12)−F(14)=18−164=764F(\tfrac12) - F(\tfrac14) = \tfrac18 - \tfrac{1}{64} = \tfrac{7}{64}. Leaving out the right endpoint changes nothing, since a single point has probability 00. By integration, x3x^3 is an antiderivative of 3x23x^2, so

∫1/41/23x2 dx=(12)3−(14)3=864−164=764.\begin{aligned} \int_{1/4}^{1/2} 3x^2\,dx &= \left(\tfrac12\right)^3 - \left(\tfrac14\right)^3 \\[0.4em] &= \tfrac{8}{64} - \tfrac{1}{64} = \tfrac{7}{64}. \end{aligned}

The two routes agree, as the fundamental theorem says they must.

  1. A random variable YY has CDF G(y)=0G(y) = 0 for y<0y < 0, G(y)=(1+y)/2G(y) = (1 + y)/2 for 0≤y<10 \le y < 1 and G(y)=1G(y) = 1 for y≥1y \ge 1. A classmate differentiates and proposes the density g(y)=12g(y) = \tfrac12 for 0<y<10 < y < 1 and g(y)=0g(y) = 0 otherwise. What goes wrong?
Show the answer

The total area under gg is 12⋅1=12\tfrac12 \cdot 1 = \tfrac12, not 11, so gg is not a density. The CDF jumps at 00, from 00 just to the left to G(0)=12G(0) = \tfrac12, so P(Y=0)=12P(Y = 0) = \tfrac12. Differentiating sees only the slope 12\tfrac12 on (0,1)(0, 1) and misses the probability that sits on the single value 00. Since every density gives each single value probability 00, the variable YY has no density at all. Its distribution combines a point mass at 00 with probability spread over (0,1)(0, 1).

How this lesson connects