Chapter 33: Gamma Random Variables
Learning Objectives
- Identify the variable and the parameters in a story, and state in English what the variable and its parameters mean.
Properties of gamma RVs
- Scenario: Modeling the time until the \(r^{th}\) event.
- Continuous analog to the Negative Binomial distribution
- Shorthand: \(X \sim \text{Gamma}(r, \lambda)\)
\[ f_X(x) = \dfrac{\lambda^r}{\Gamma(r)}x^{r-1} e^{-\lambda x}\text{ for } x>0, \lambda>0, \Gamma(r) = (r-1)! \]
\[ F_X(x) = \left\{ \begin{array}{ll} 0 & \quad x<0 \quad \\ 1 - e^{-\lambda x}\displaystyle\sum_{j=0}^{r-1}\dfrac{(\lambda x)^j}{j!} & \quad x\geq0 \\ \end{array} \right. \]
\[\text{E}(X) = \dfrac{r}{\lambda}\text{, }\text{ Var}(X) = \dfrac{r}{\lambda^2}\]
Common to see \(\alpha = r\) and \(\beta = \lambda\)
Identifying gamma RV from word problems
Gamma distribution with \(r=1\) is same as exponential
- Just like Negative Binomial with \(r=1\) is same as the geometric distribution
Similar to exponential
- Look for time between or until events/successes
- BUT now we are measuring time until more than 1 success
- Look for a rate of the events over time period
- Look for time between or until events/successes
Helpful R code
Let’s say we’re sitting at the bus stop, measuring the time until 4 buses arrive. We know the bus comes every 10 minutes on average.
If we want to know the probability that the 4 buses arrive in the next 50 minutes:
pgamma(q = 50, rate = 1/10, shape = 4)
[1] 0.7349741
pgamma(q = 50, scale = 10, shape = 4)
[1] 0.7349741
If we want to know the time, say \(t\), where the probability of the 4 buses arriving at \(t\) or earlier is 0.35:
qgamma(p = 0.35, rate = 1/10, shape = 4)
[1] 29.87645
If we want to know the probability that the 4 buses arrives between 30 and 50 minutes:
pgamma(q = 50, scale = 10, shape = 4) - pgamma(q = 30, scale = 10, shape = 4)
[1] 0.382206
If we want to sample 20 arrival times for the 4 buses:
rgamma(n = 20, scale = 10, shape = 4)
[1] 23.62559 67.87353 66.09070 37.22996 26.01786 69.19651 33.56302 41.93588 [9] 18.28835 76.26211 74.34490 51.98992 15.32024 50.57118 73.52642 36.96576 [17] 66.41893 17.71069 30.96120 21.86717
Remarks
The parameter \(r\) in a Gamma(\(r\),\(\lambda\)) distribution does NOT need to be a positive integer
- \(r\) is usually a positive integer
When \(r\) is a positive integer, the distribution is sometimes called an Erlang(\(r\),\(\lambda\)) distribution
When \(r\) is any positive real number, we have a general gamma distribution that is usually instead parameterized by \(\alpha>0\) and \(\beta>0\), where:
\(\alpha = \text{shape parameter}\) : same as \(k\), the total number of events we must witness
- In R code example: 4 buses to wait for
\(\beta = \text{scale parameter}\) : same as \(\lambda\), the rate parameter
- In R code example: 1 bus per 10 minutes (1/10)
Sending money orders
Example 1
On average, someone sends a money order once per 15 minutes. What is the probability someone sends 10 money orders in less than 3 hours?
Additional Resource
- Another helpful site with R code: https://rpubs.com/mpfoley73/459051