1 Normal Distibution

In this section we will explore the normal distribution.

1.1 Fixed mean, varying standard deviation

Set \(\mu = 5\). For values of \(\sigma\) given by \(0.2, 0.4, 0.8, 1, 1.3, 1.8, 2\), plot the densities of \(N(\mu, \sigma)\) in the same plot. It might help if (1) you have the densities of \(N(\mu = 5, \sigma = 0.2)\) and \(N(\mu = 5, \sigma = 2)\) to be blue in color and the rest to be red. (2) choose appropriate limits for the x-axis (use x_lim parameter in the plot funtion) and y-axis (use y_lim).

X <- seq(0,10,length=1000)
plot(X, dnorm(X,5, 0.2), type="l",col="blue")
lines(X, dnorm(X,5, 0.4), type="l",col="red")
lines(X, dnorm(X,5, 0.8), type="l",col="red")
lines(X, dnorm(X,5, 1), type="l",col="red")
lines(X, dnorm(X,5, 1.3), type="l",col="red")
lines(X, dnorm(X,5, 1.8), type="l",col="red")
lines(X, dnorm(X,5, 2), type="l",col="blue")

What do you notice about the plot? Comment about how the width changes.

1.2 Varying mean, fixed standard deviation

Set \(\sigma = 0.4\). For values of \(\mu\) given by \(-1, -0.5, 0, 0.4, 0.9, 2.5, 4\) plot the densities of \(N(\mu, \sigma)\) in the same plot. You might need to choose appropriate limits for the x-axis.

X <- seq(-3,6,length=1000)
plot(X, dnorm(X,-1, 0.4), type="l",col="blue")
lines(X, dnorm(X,-0.5, 0.4), type="l",col="red")
lines(X, dnorm(X,0, 0.4), type="l",col="red")
lines(X, dnorm(X,0.4, 0.4), type="l",col="red")
lines(X, dnorm(X,0.9, 0.4), type="l",col="red")
lines(X, dnorm(X,2.5, 0.4), type="l",col="red")
lines(X, dnorm(X,4, 0.4), type="l",col="blue")

2 Gamma Distibution

We will plot the Gamma distibution for different shapes and scales. You might need to adjust the limits of x and y axes appropriately.

2.1 \(\alpha =1\) , varying scales

Set \(\alpha = 1\), vary \(\beta\) over \(0.2, 0.6, 1, 1.5, 2\). Plot the densities of \(Gamma(\alpha, \beta)\) in a single plot.

X <- seq(0,20,length=1000)
plot(X, dgamma(X,1,0.2), type="l",col="blue",ylim = c(0,2.1))
lines(X, dgamma(X,1,0.6), type="l",col="red")
lines(X, dgamma(X,1,1), type="l",col="red")
lines(X, dgamma(X,1,1.5), type="l",col="red")
lines(X, dgamma(X,1,2), type="l",col="blue")

2.2 \(\alpha =0.6\) , varying scales

Set \(\alpha = 0.6\), vary \(\beta\) over \(0.2, 0.6, 1, 1.5, 2\). Plot the densities of \(Gamma(\alpha, \beta)\) in a single plot.

X <- seq(0,20,length=1000)
plot(X, dgamma(X,0.6,0.2), type="l",col="blue",ylim = c(0,2.1))
lines(X, dgamma(X,0.6,0.6), type="l",col="red")
lines(X, dgamma(X,0.6,1), type="l",col="red")
lines(X, dgamma(X,0.6,1.5), type="l",col="red")
lines(X, dgamma(X,0.6,2), type="l",col="blue")

2.3 \(\alpha = 2\) , varying scales

Set \(\alpha = 2\), vary \(\beta\) over \(0.2, 0.6, 1, 1.5, 2\). Plot the densities of \(Gamma(\alpha, \beta)\) in a single plot.

X <- seq(0,20,length=1000)
plot(X, dgamma(X,2,0.2), type="l",col="blue",ylim = c(0,2.1))
lines(X, dgamma(X,2,0.6), type="l",col="red")
lines(X, dgamma(X,2,1), type="l",col="red")
lines(X, dgamma(X,2,1.5), type="l",col="red")
lines(X, dgamma(X,2,2), type="l",col="blue")

2.4 \(\alpha = 5\) , varying scales

Set \(\alpha = 5\), vary \(\beta\) over \(0.2, 0.6, 1, 1.5, 2\). Plot the densities of \(Gamma(\alpha, \beta)\) in a single plot.

X <- seq(0,20,length=1000)
plot(X, dgamma(X,5,0.2), type="l",col="blue",ylim = c(0,2.1))
lines(X, dgamma(X,5,0.6), type="l",col="red")
lines(X, dgamma(X,5,1), type="l",col="red")
lines(X, dgamma(X,5,1.5), type="l",col="red")
lines(X, dgamma(X,5,2), type="l",col="blue")