15.10 - Trick To Avoid Integration
15.10 - Trick To Avoid IntegrationSometimes taking the integral is not an easy task. We do have some tools, however, to help avoid some of them. Let's take a look at an example.
Suppose we have a random variable, \(X\), that has a Gamma distribution and we want to find the Moment Generating function of \(X\), \(M_X(t)\). There is an example of how to compute this in the notes but let's try it another way.
\(\begin{align*} M_X(t)&=\int_0^\infty \frac{1}{\Gamma(\alpha)\beta^\alpha} x^{\alpha-1}e^{-x/\beta}e^{tx}dx\\ & = \int_0^\infty \frac{1}{\Gamma(\alpha)\beta^\alpha} x^{\alpha-1}e^{-x\left(\frac{1}{\beta}-t\right)}dx \end{align*}\)
Let's rewrite this integral, taking out the constants for now and rewriting the exponent term.
\(\begin{align*} M_X(t)&= \frac{1}{\Gamma(\alpha)\beta^\alpha}\int_0^\infty x^{\alpha-1}e^{-x\left(\frac{1}{\beta}-t\right)}dx\\ & =\frac{1}{\Gamma(\alpha)\beta^\alpha}\int_0^\infty x^{\alpha-1}e^{-x\left(\frac{1-\beta t}{\beta}\right)}dx\\ & = \frac{1}{\Gamma(\alpha)\beta^\alpha}\int_0^\infty x^{\alpha-1}e^{-x/\left(\frac{\beta}{1-\beta t}\right)}dx\\ & = \frac{1}{\Gamma(\alpha)\beta^\alpha}\int_0^\infty g(x)dx \end{align*}\)
When we rewrite it this way, the term under the integral, \(g(x)\), looks almost like a Gamma density function with parameters \(\alpha\) and \(\beta^*=\dfrac{\beta}{1-\beta t}\). The only issues that we need to take care of are the constants in front of the integral and the constants to make \(g(x)\) a gamma density function.
To make \(g(x)\) a Gamma density function, we need the constants. Therefore, we need a \(\dfrac{1}{\Gamma(\alpha)}\) term and a \(\dfrac{1}{(\beta^*)^\alpha}\) term. We already have the first term, so lets rewrite the function.
\(M_X(t)=\frac{1}{\beta^\alpha}\int_0^\infty \frac{1}{\Gamma(\alpha)}x^{\alpha-1}e^{-x/\left(\frac{\beta}{1-\beta t}\right)}dx\)
All that is left is the \(\dfrac{1}{(\beta^*)^\alpha}\).
\(\frac{1}{(\beta^*)^\alpha}=\frac{1}{\left(\frac{\beta}{1-\beta t}\right)^\alpha}=\frac{\left(1-\beta t\right)^\alpha}{\beta^\alpha}\)
We have the denominator term already. Lets rewrite just for clarity.
\(M_X(t)=\int_0^\infty \frac{1}{\Gamma(\alpha)\beta^\alpha}x^{\alpha-1}e^{-x/\left(\frac{\beta}{1-\beta t}\right)}dx\)
Since \(\dfrac{1}{(\beta^*)^\alpha}=\dfrac{\left(1-\beta t\right)^\alpha}{\beta^\alpha}\), we need only to include the \((1-\beta t) ^\alpha\) term. If we include the term in the integral, we have to multiply by one. Therefore,
\( \begin{align*} & M_X(t)=\left(\frac{(1-\beta t)^\alpha}{(1-\beta t)^\alpha}\right)\int_0^\infty \frac{1}{\Gamma(\alpha)\beta^\alpha}x^{\alpha-1}e^{-x/\left(\frac{\beta}{1-\beta t}\right)}dx\\ & = \left(\frac{1}{(1-\beta t)^\alpha}\right)\int_0^\infty \frac{(1-\beta t)^\alpha}{\Gamma(\alpha)\beta^\alpha}x^{\alpha-1}e^{-x/\left(\frac{\beta}{1-\beta t}\right)}dx\\ & \left(\frac{1}{(1-\beta t)^\alpha}\right)\int_0^\infty \frac{1}{\Gamma(\alpha)\left(\frac{\beta}{1-\beta t}\right)^\alpha}x^{\alpha-1}e^{-x/\left(\frac{\beta}{1-\beta t}\right)}dx\\ & \left(\frac{1}{(1-\beta t)^\alpha}\right)\int_0^\infty h(x) dx \end{align*}\)
Therefore, \(h(x)\) is now a Gamma density function with parameters \(\alpha\) and \(\beta^*=\dfrac{\beta}{1-\beta t}\). And, since \(h(x)\) is a pdf and we are integrating over the whole space, \(x\ge 0\), then \(\int_0^\infty h(x)dx=1\). If the integral is equal to 1 based on the definition of a pdf, we are left with:
\(M_X(t)=\dfrac{1}{(1-\beta t)^\alpha}\left(1\right)=\dfrac{1}{(1-\beta t)^\alpha}\)
From the notes and the text, you can see that the moment generating function calculated above is exactly what we were supposed to get.
Just to summarize what we did here. We did not actually calculate the integral. We used algebra to manipulate the function to use the definition of a pdf. I find that after practice, this method is a lot quicker for me than doing the integrals.
Additional Practice Problems
These problems are not due for homework.
-
Find \(E(X)\) using the method above.
\(\begin{align*} E(X)&=\int_0^\infty x\frac{1}{\Gamma(\alpha)\beta^\alpha}x^{\alpha-1}e^{-x/\beta}dx\\[5 pt] &=\frac{1}{\Gamma(\alpha)\beta^{\alpha}}\int_0^\infty x^{\alpha}e^{-x/\beta}dx\\[5 pt] &=\left(\frac{1}{\Gamma(\alpha)\beta^{\alpha}}\right)\left(\frac{\Gamma(\alpha+1)\beta^{\alpha+1}}{\Gamma(\alpha+1)\beta^{\alpha+1}}\right)\int_0^\infty x^{\alpha}e^{-x/\beta}dx\\[5 pt] &=\left(\frac{\Gamma(\alpha+1)\beta^{\alpha+1}}{\Gamma(\alpha)\beta^{\alpha}}\right)\int_0^\infty \left(\frac{1}{\Gamma(\alpha+1)\beta^{\alpha+1}}\right) x^{\alpha}e^{-x/\beta}dx \\[5 pt] &=\frac{\Gamma(\alpha+1)\beta^{\alpha+1}}{\Gamma(\alpha)\beta^{\alpha}}(1)\\[5 pt] &=\frac{\alpha\Gamma(\alpha)\beta}{\Gamma(\alpha)}\\[5 pt]&=\alpha\beta \end{align*}\)
-
Find \(E(X^2)\) using the method above.
\(\begin{align*} E(X^2)&=\int_0^\infty x^2\frac{1}{\Gamma(\alpha)\beta^\alpha}x^{\alpha-1}e^{-x/\beta}dx\\[5 pt]&=\frac{1}{\Gamma(\alpha)\beta^{\alpha}}\int_0^\infty x^{\alpha+1}e^{-x/\beta}dx\\[5 pt]&=\left(\frac{1}{\Gamma(\alpha)\beta^{\alpha}}\right)\left(\frac{\Gamma(\alpha+2)\beta^{\alpha+2}}{\Gamma(\alpha+2)\beta^{\alpha+2}}\right)\int_0^\infty x^{\alpha+1}e^{-x/\beta}dx\\[5 pt]&=\left(\frac{\Gamma(\alpha+2)\beta^{\alpha+2}}{\Gamma(\alpha)\beta^{\alpha}}\right)\int_0^\infty \left(\frac{1}{\Gamma(\alpha+2)\beta^{\alpha+2}}\right) x^{\alpha+1}e^{-x/\beta}dx\\[5 pt]& =\frac{\Gamma(\alpha+2)\beta^{\alpha+2}}{\Gamma(\alpha)\beta^{\alpha}}(1)\\[5 pt]&=\frac{(\alpha+1)\Gamma(\alpha+1)\beta^2}{\Gamma(\alpha)}\\[5 pt]&=\alpha(\alpha+1)\beta^2 \end{align*}\)