Problem 4.79 (2 Points)

If \(\lambda > 0\) and \(\alpha\) is a positive integer, the relationship between incomplete gamma integrals and sums of Poisson probabilities is given by \[ \frac{1}{\Gamma(\alpha)} \int_{\lambda}^{\infty} y^{\alpha-1}e^{-y}\,dy = \sum_{x=0}^{\alpha-1}\frac{\lambda^{x}e^{-\lambda}}{x!}. \] If \(Y\) has a gamma distribution with \(\alpha = 2\) and \(\beta = 1\), find \(P(Y > 1)\) by using the preceding equality and Table \(3\) of Appendix III.

Solution 4.79

Let \(X\) have a Poisson distribution with expected value \(\lambda = 1\). Using the above equation, we have \[ P(Y > 1) = \frac{1}{\Gamma(2)} \int_{1}^{\infty} y^{2-1}e^{-y}\,dy = \sum_{x=0}^{2-1}\frac{1^{x}e^{-1}}{x!} = P(X\le 1). \] Using Table \(3\) on page \(787\), we find that \(P(X\le 1)\doteq 0.736\). We can find the same value with the R command ppois(1,lambda = 1)

[1] 0.7357589

Problem 4.89 (10 Points)

Let the random variable \(Y\) have the Gamma probability distribution with parameters \(\alpha>0\) and \(\beta>0\). Then the probability density function for \(Y\) is \[ f(y;\alpha,\beta) = \begin{cases} \frac{y^{\alpha-1}e^{-y/\beta}}{\beta^{\alpha}\Gamma(\alpha)} &, y>0 \\ 0 &, \text{otherwise.} \end{cases} \]
  1. Let \(a\) be any real number for which \(\alpha+a>0\). \[\begin{align*} \beta^\alpha\Gamma(\alpha)\, E[Y^a] &= \int_0^\infty y^a y^{\alpha-1} e^{-y/\beta}\,dy \\ &= \int_0^\infty y^{\alpha+a-1} e^{-y/\beta}\,dy \\ &= \beta^{\alpha+a}\Gamma(\alpha+a). \end{align*}\] Therefore, \(E[Y^a]=\beta^a \Gamma(\alpha+a) / \Gamma(\alpha)\).
  2. If \(\alpha+a\le 0\) then \(\alpha+a-1\le -1\) and the improper integral in part (a) will diverge at 0.
  3. Let \(a=1\). Then by part (a) \[ \mu = E[Y] = \beta\frac{\Gamma(\alpha+1)}{\Gamma(\alpha)} = \beta\frac{\alpha \Gamma(\alpha)}{\Gamma(\alpha)} = \alpha \beta. \] Therefore \(\mu = \alpha \beta\).
  4. By part (a), \(E[\sqrt{Y}] = E[Y^{1/2}] = \beta^{1/2}\Gamma(\alpha+1/2)/\Gamma(\alpha)\). This holds for all \(\alpha>0\).
  5. By part (a) \[\begin{align*} E[1/Y] &= \beta^{-1}\frac{\Gamma(\alpha-1)}{\Gamma(\alpha)} = \frac{1}{\beta (\alpha-1)}, & \alpha > 1. \\ E[1/\sqrt{Y}] &= \beta^{-1/2}\frac{\Gamma(\alpha-\frac{1}{2})}{\Gamma(\alpha)}, & \alpha > \frac{1}{2}. \\ E[1/Y^2] &= \beta^{-2}\frac{\Gamma(\alpha-2)}{\Gamma(\alpha)} = \frac{1}{\beta^2 (\alpha-1) (\alpha-2)}, & \alpha > 2. \end{align*}\]

Problem 4.90 (8 Points)

Let the random variable \(Y\) have the chi-square distribution with \(\nu\) degrees of freedom, where \(\nu\) can be any positive integer. Then \(Y\) has a Gamma distribution with \(\alpha=\nu/2\) and \(\beta=2\).
  1. By 4.89(a), \(E[Y^a]=2^a\Gamma(\frac{1}{2}\nu+a)/\Gamma(\frac{1}{2}\nu)\).
  2. \(\alpha+a > 0\) if and only if \(2\alpha = \nu > -2a\).
  3. By part (a), \(E[\sqrt{Y}]=\sqrt{2}\,\Gamma(\frac{1}{2}\nu+\frac{1}{2})/\Gamma(\frac{1}{2}\nu)\).
  4. By part (a) \[\begin{align*} E[1/Y] &= \frac{1}{2(\frac{1}{2}\nu-1)} = \frac{1}{\nu-2}, &\nu > 2. \\ E[1/\sqrt{Y}] &= \frac{\Gamma(\frac{1}{2}\nu-\frac{1}{2})}{\sqrt{2}\, \Gamma(\frac{1}{2}\nu)}, & \nu > 1. \\ E[1/Y^2] &= \frac{1}{2^2(\frac{1}{2}\nu -1)(\frac{1}{2}\nu - 2)} = \frac{1}{(\nu - 2)(\nu - 4)}, & \nu > 4. \end{align*}\]

Problem 6.14 (6 Points)

A member of the Pareto family of distributions (often used in economics to model income distributions) has a distribution function given by \[ F(y) = \begin{cases} 0, & y < \beta \\ 1 - \left(\frac{\beta}{y}\right)^{\alpha}, & y \ge \beta, \end{cases} \] where \(\alpha > 0\) and \(\beta > 0\).

  1. Find the density function.

    The density function, \(f(y)\), is the derivative of the distribution function, \(F(y)\). Therefore, \[ f(y) = \begin{cases} 0, & y \le \beta \\ \frac{\alpha \beta^{\alpha}}{y^{\alpha+1}}, & y > \beta. \end{cases} \]
  2. For fixed values of \(\beta\) and \(\alpha\), find a transformation \(G(U)\) so that \(G(U)\) has the distribution function of \(F\) when \(U\) has a uniform distribution on the interval \((0,1)\).

    For \(0 < u < 1\), the distribution function for \(U\) is \(F_U(u) = u\). Thus, we need to find a function \(y = G(u)\) such that \[ F_U(u) = F(y). \] So, we need to solve the equation \(u = 1 - (\beta / y)^{\alpha}\) for \(y\). After some routine algebra, we find that \(y = \beta / (1- u)^{1/\alpha}\). Therefore \[ Y = \beta / (1 - U)^{1/\alpha} \] will transform the uniform distribution on \((0,1)\) to \(F\).
  3. Given that a random sample of size \(5\) from a uniform distribution on the interval \((0,1)\) yielded the values \(0.0058, 0.2048, 0.7692, 0.2475\) and \(0.6078\), use the transformation derived in (b) to give values associated with a random variable with a Pareto distribution with \(\alpha=2\), \(\beta=3\).

    We will use R to do these tedius calculations.

    alpha <- 2  # Set alpha to 2
    beta <- 3   # Set beta to 3
    # Define the transformation G
    G <- function(u) {beta / (1 - u)^(1/alpha)} 
    # Set u to a vector that contains the uniform random sample.
    # We use the function "c()" to create a vector of reals.
    u <- c(0.0058, 0.2048, 0.7692, 0.2475, 0.6078)
    # Apply the transformation G to the values in u.
    G(u)
    [1] 3.008738 3.364210 6.244582 3.458343 4.790352
    # As a sanity check, confirm that all 5 values
    # are greater than 3, i.e. greater than beta.

Problem 6.40 (2 Points)

Let \(n\) be a positive integer and let \(Y\) have a Gamma distribution with parameters \(\alpha=n/2\) and \(\beta>0\). Using Table A2.2 in Appendix Two \[ m_Y(t) = (1 - \beta\, t)^{-n/2} = E\left[e^{t Y}\right]. \] Let \(W=2Y/\beta\), then \[\begin{align*} m_W(t) &= E\left[e^{t W}\right] \\ &= E\left[e^{(2t/\beta) Y}\right] \\ &= m_Y(2t/\beta) \\ &= \left[1 - \beta\left(\frac{2t}{\beta}\right)\right]^{-n/2} \\ &= (1 - 2t)^{-n/2}, \end{align*}\]

which, by Table A2.2, is the moment generating function for a chi-square distributed random variable with \(\nu=n\) degrees of freedom. Therefore, by Theorem 6.1 (page 302), \(W\) has a chi-square distribution with \(n\) degrees of freedom.

Problem (2 Points)

Let \(Y_1\) and \(Y_2\) be independent random variables with respective probability distributions Poisson(\(\lambda_1\)) and Poisson(\(\lambda_2\)). By Table A2.1 in Appendix Two, the respective moment generating functions are \[\begin{align*} m_{Y_1}(t) &= \exp[\lambda_1 (e^t - 1)] \\ m_{Y_2}(t) &= \exp[\lambda_2 (e^t - 1)]. \end{align*}\]

Let \(Y = Y_1 + Y_2\). Since \(Y_1\) and \(Y_2\) are independent random variables, Theorem 6.2 (page 304) implies that the moment generating function for \(Y\) is \[ m_Y(t) = m_{Y_1}(t)\cdot m_{Y_2}(t) = \exp[(\lambda_1 + \lambda_2) (e^t - 1)], \] which, by Table A2.1, is the moment generating function for a random variable that has a Poisson(\(\lambda_1 + \lambda_2\)) distribution. Therefore, by Theorem 6.1 (page 302), the random variable \(Y\) has a Poisson(\(\lambda_1+\lambda_2\)) probability distribution. In other words, the sum of independent Poisson random variables with means \(\lambda_1\) and \(\lambda_2\) is a Poisson random variable with mean \(\lambda_1 + \lambda_2\).

Problem (4 Points)

Let \(Y_1\) and \(Y_2\) be independent and identically distributed Exponential random variables with common mean \(E[Y_1] = E[Y_2] = \beta\). By Table A2.2 in Appendix Two, the (identical) moment generating functions are \[ m(t) = (1 - \beta\,t)^{-1}. \] Let \(Y = Y_1 + Y_2\). Since \(Y_1\) and \(Y_2\) are independent random variables, Theorem 6.2 (page 304) implies that the moment generating function for \(Y\) is \[ m_Y(t) = m(t)\cdot m(t) = m(t)^2 = (1 - \beta\,t)^{-2}, \] which, by Table A2.2, is the moment generating function for a random variable that has a Gamma probability distribution with parameters \(\alpha=2\) and \(\beta\). Therefore, by Theorem 6.1 (page 302), the random variable \(Y\) has a Gamma(\(2,\beta\)) probability distribution.

Now, let \(Y_1,\dotsc,Y_n\) be independent and identically distributed Exponential(\(\beta\)) random variables. As an induction hypothesis, assume that the random variable \(Y_1 + \dotsb + Y_{n-1}\) has a Gamma(\(n-1,\beta\)) distribution. Let \[ Y = Y_1 + \dotsb + Y_{n-1} + Y_n = (Y_1 + \dotsb + Y_{n-1}) + Y_n. \] Then, by the induction hypothesis, \(Y\) is the sum of a Gamma(\(n-1,\beta\)) distributed random variable and an Exponential(\(\beta\)) distributed random variable. The independence of \(Y_1,\dotsc,Y_n\) implies that \((Y_1 + \dotsb + Y_{n-1})\) and \(Y_n\) are independent random variables. Therefore, using Table A2.2 and Theorem 6.2, the moment generating function for \(Y\) is \[ m(t) = (1-\beta\,t)^{-n+1}\cdot (1-\beta\,t)^{-1} = (1 - \beta\,t)^{-n}, \] which, by Table A2.2, is the moment generating function for a random variable that has a Gamma probability distribution with parameters \(\alpha=n\) and \(\beta\). Therefore, by Theorem 6.1 (page 302), the random variable \(Y\) has a Gamma(\(n,\beta\)) probability distribution. In other words, the sum of \(n\) independent and identically distributed Exponential(\(\beta\)) random variables is a Gamma(\(n,\beta\)) distributed random variable.

LS0tCnRpdGxlOiAiU29sdXRpb25zIHRvIEhvbWV3b3JrIEFzc2lnbm1lbnQgMSIKb3V0cHV0OiBodG1sX25vdGVib29rCmhlYWRlci1pbmNsdWRlczogXHVzZXBhY2thZ2V7YW1zbWF0aH0KLS0tCgojIyBQcm9ibGVtIDQuNzkgKDIgUG9pbnRzKQpJZiAkXGxhbWJkYSA+IDAkIGFuZCAkXGFscGhhJCBpcyBhIHBvc2l0aXZlIGludGVnZXIsIHRoZSByZWxhdGlvbnNoaXAgYmV0d2VlbiBpbmNvbXBsZXRlIGdh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