The Chi-Square Distribution
Recall that the Gamma distribution has several special cases depending on its parameters α and β. Using the dgamma function in R, we can graph a few cases. The dgamma commonly takes in a vector, a rate (alpha) and a shape (Beta).
exp_seq <- seq(0, 7, .001) #sequence from 0 to 5 by .001 plot(exp_seq, dgamma(exp_seq, 1,1), col="red", main="Gamma Density Distribution", xlab="x", ylab="f(x)", cex=0.02) lines(exp_seq, dgamma(exp_seq, 2, 1), col="orange") lines(exp_seq, dgamma(exp_seq, 3, 1), col="yellow") lines(exp_seq, dgamma(exp_seq, 4, 1), col="green") lines(exp_seq, dgamma(exp_seq, 5, 1), col="blue") legend(4.5, 1, legend=c("α=1, β=1", "α=2, β=1", "α=3, β=1", "α=4, β=1", "α=5, β=1"), col=c("red", "orange", "yellow", "green", "blue"), lty=1, cex=0.8)
The Exponential is a special case of the Gamma Distribution with Γ(α=1, β=1/λ) .
The Chi-square (χ²) is also special case of the Gamma distribution, with Γ(α=½, β=2). To see this, let Z be a standard normal random variable from ~N(0,1). If you square Z, then Z² is a chi-square variable with degrees of freedom 1 notated here as χ²₁ .
Take a look at the transformation of a standard normal graph squared.
# z is standard normal N(0,1) z <- rnorm(n = 10000, mean = 0, sd = 1) hist(z)
# Creating a chi-square distribution by squaring the values x = z^2 hist(x, bins=5)
Notice the shape of the chi-square distribution is similar to a gamma density distribution. This can be proved using the definition above and the Distribution Function Technique. If Z~N(0,1) and X=Z², then x~χ²₁.
Take the derivative of the cdf to find the pdf.
Since Z follows a standard normal distribution:
This simplifies to:
This is the pdf for Γ(α=½, β=2) and it is called a chi-square of degrees of freedom 1.
The t Distribution
A t distribution is created using the ratio of a standard normal and the square root of a chi-square divided by its degrees of freedom.
Z ~ N(0,1)
U ~χ²nis a t distribution with n degrees of freedom.
The following graph shows how several t distributions compare to the standard normal curve.
curve(dnorm(x), -4.5, 4.5, col = "red") curve(dt(x, df = 1), add = TRUE) curve(dt(x, df = 5), add = TRUE) curve(dt(x, df = 15), add = TRUE)
The pdf of the t distribution with n degrees of freedom is quite complicated, but its expected value is 0 and the variance is n/n-2. As the degrees of freedom increase, the t distribution tends toward the standard normal (notice the variance approaches 1 as n⇒∞). This can be seen in the graph as well. The tails of the t distribution as higher but they approach N(0,1) as the degrees of freedom increase.
The F Distribution
Let U ~ χ²n and V ~ χ²m. If U and V are independent then the ratio of
is an F distribution notated F n,m.
f_seq <- seq(0, 7, .001) f_dist <- df(f_seq, df1 = 3, df2 = 4) plot(f_dist, main = "F-Distribution w/ df1=3 and df2=4")