# Computing the derivative of the CDF of a gamma random variable

In class, my professor computed the density of a gamma random variable by taking the derivative of its CDF, but he skipped many steps. I am trying to go through the derivation carefully but cannot reproduce his final result.

Let $$k$$ be the shape and $$\mu$$ be the scale. Then the CDF for a gamma random variable $$T$$ is

$$F(t) = 1 - \sum_{i=0}^{k-1} \frac{e^{-\mu t} (\mu t)^{i}}{i!}$$

Using the product rule, I get

\begin{align} f(t) &= \frac{\partial}{\partial t} F(t) \\ &= \frac{\partial}{\partial t} \Big( 1 - \sum_{i=0}^{k-1} \frac{e^{-\mu t} (\mu t)^{i}}{i!} \Big) \\ &= - \sum_{i=0}^{k-1} \frac{\partial}{\partial t} \Big( \frac{e^{-\mu t} (\mu t)^{i}}{i!} \Big) \\ &= - \sum_{i=0}^{k-1} \frac{1}{i!} \frac{\partial}{\partial t} \Big( e^{-\mu t} (\mu t)^{i} \Big) \end{align}

where

$$\frac{\partial}{\partial t} \Big( e^{-\mu t} (\mu t)^{i} \Big) = e^{-\mu t} (-\mu)(\mu t)^i + e^{-\mu t} i (\mu t)^{i-1}$$

Putting everything together, we get

$$f(t) = \sum_{i=0}^{k-1} \frac{\mu e^{-\mu t} (\mu t)^i}{i!} - \sum_{i=0}^{k-1} \frac{e^{-\mu t} (\mu t)^{i-1}}{(i-1)!}$$

But here I am stuck. I know that

$$f(t) = \frac{\mu e^{-\mu t} (\mu t)^{k-1}}{(k-1)!}$$

but am not sure how to get there.

• You have some omissions in your product and chain rules line: $$\frac{\partial}{\partial t} (\dots)= \mathrm{e}^{- \mu t} (-\mu) (\mu \underline{t})^i + \mathrm{e}^{-\mu t} \underline{i} \mu (\mu t)^{i-1} \text{.}$$ – Eric Towers Mar 14 at 15:21
• Thanks. The first one was a typo but the second was a mistake and critical for factoring. – gwg Mar 14 at 21:32

a) note that the second sum starts from $$i=1$$;
that's because when you derivate $$\frac{(\mu t)^i}{i!}$$ you get $$\frac{i(\mu t)^{i-1}}{i!}$$ which is $$0$$ for $$i=0$$, and only for $$1 \le i$$ becomes $$\frac{(\mu t)^{i-1}}{(i-1)!}$$
b) factor out $$e^{-\mu t}$$
• Thanks, this worked. Just to clarify, I factored out $\mu e^{- \mu t}$. If a term in a series is undefined, is it mathematically acceptable to just remove that term by updating the index (your first point above). – gwg Mar 14 at 21:34
• Glad it helped. But concerning the index of second sum, no, $0$ is not removed because $(i-1)!$ is otherwise not defined (which is not allowed, and just indicates there is a fault somewhere), it is the result of the derivation : I added a note in the answer. – G Cab Mar 14 at 23:39
You might also want to manually check what's going on with the first one or two terms in the sum for $$F$$ as you take the derivative, since introducing "$$(-1)!$$" is not happening. (That is, you have divided by zero in your shown work.)