Next: Examples Up: Simulation of random variables Previous: Simulation of random variables

### Additional notes: simulation of the Gamma distribution

The Gamma distribution is a two-parameter family with alternative parameterizations. The density function is

where is called the shape parameter, is called the scale parameter, and is called the rate parameter. The expected value and standard deviation of the gamma distribution are,

It usually is more natural to specify the distribution in terms of its mean and s.d., . The relationship between and can be inverted to obtain the natural parameters of this distribution in terms of its mean and s.d. That is,

The plot below shows why is called the shape parameter.

This plot was generated by the following R code.

n = 100 # sample size
N = 400 # num x-values
mu = c(.75,1,5) # means
Gam.col = c("red","ForestGreen","blue")
sig = 1 # s.d.'s
alpha = (mu/sig)^2
beta = (sig^2)/mu
x = seq(0.05,8,length=N)
y1 = dgamma(x,alpha[1],scale=beta[1])
%y2 = dgamma(x,alpha[2],scale=beta[2])
%y3 = dgamma(x,alpha[3],scale=beta[3])
%Y = cbind(y1,y2,y3)
%plot(x,y1,xlab="",ylab="Density",ylim=range(Y),type="n")
%for(k in seq(mu)) {
%  lines(x,Y[,k],col=Gam.col[k],lwd=1.5)
%}
%legend(x[N],max(Y),legend=paste("Mean =",mu),
%       lty=1,col=Gam.col,xjust=1)
%title("Gamma Densities")
%mtext(paste("SD =",sig[1]),side=1,line=2)
%graphics.off()


Note that the Chi-square distribution is a special case of the gamma distribution with

shape = df/2
scale = 2 (rate = 1/2).


ammann
2017-12-10