MATH 335: Gamma distribution

In R, we say

help(pgamma)

to get help about the pgamma function.

Notice that the help message gives help on several functions related to the gamma. This bonus information is how R creates help messages for any of its built in probability distributions. Click Here to see a list of available distributions.

Example: Fumbles. Suppose that in NCAA Division I football, the act of fumbling behaves as a Poisson process with rate parameter given by lambda = .043 fumbles per minute of play. Lets compute the distribution (pdf) for the time required to observe the third fumble in a game or series of games.

Then the distribution of Y will be a gamma with lambda=.043 and r=3. Let's use R code to see a graph of the pdf:


xx <- seq(0,300,length=301)
yy <- dgamma(xx,3,.043)
plot(xx,yy,type='l')

Suppose our favorite team has 4 games remaining on its schedule. What is the probability it will not accrue 3 fumbles over this period? We compute P(Y > 240) using R:
1-pgamma(240,3,.043)
[1] 0.002128726

Here is a function for drawing the graph of a gamma pdf.

# A function to draw graphs of Gamma pdf's.
# 
draw <- function(a,b,min,max) {
        #
        # a=shape, b=scale = 1/rate
        #
        x <- seq(min,max, length=101)
        y <- dgamma(x,a,scale=b)
        plot(x,y,type='l',main=unlist(list("shape=",a,"scale=",b)))
        #title(main=list("shape=",a,"scale=",b))
	}

Enter that function into R. Then run the following code to see a collection of gamma pdf's.


m <- 4
n <- 3
par(mfrow=c(m,n))

for (i in 1:m) {
   for (j in 1:n) {
     draw(2^i,j,0,30)
     }
     }
par(mfrow=c(1,1))