We want to graph the five symmetric distributions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # display the five symmetric distributions # These five symmetric distributions are Uniform(-sqrt(3)<x<sqrt(3)), # Nomal, Logistric, Double Expenential, Cauchy x <- seq(-4,4,length=100) hx <- dnorm(x) hx1 <- dunif(x,min=-sqrt(3),max=sqrt(3)) hx2 <- dlogis(x,location = 0, scale = 1) hx3 <- dcauchy(x) hx4 <- dlaplace(x) par(mfrow = c(3,2)) plot(x,hx,type="l",main = "Normal Distribution",col="red") plot(x,hx1,type='l',main = "Uniform distribution",col = "blue") plot(x,hx2,type="l",main = "Logistic Distribution", col= "yellow") plot(x,hx3,type="l",main = "Cauchy Distribution",col="green") plot(x,hx4,type="l",main = "Double Exponential Distribution",col="black") |
The result would be :

If We want to graph the five distributions in one plot, the code should be
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # display the five symmetric distributions in one plot x <- seq(-4,4,length=100) hx <- dnorm(x) hx1 <- dunif(x,min=-sqrt(3),max=sqrt(3)) hx2 <- dlogis(x,location = 0, scale = 1) hx3 <- dcauchy(x) hx4 <- dlaplace(x) labels <- c("Normal","Uniform","Logistic","Cauchy","Double Exponatial") cols <- c("red","blue","yellow","green","black") plot(x,hx4,type="l",main = "five Distributions",col=cols[5]) lines(x,hx,col=cols[1]) lines(x,hx1,col=cols[2]) lines(x,hx2,col=cols[3]) lines(x,hx3,col=cols[4]) legend("topright", inset=.05, title="Distributions", labels, lty=c(1, 1, 1, 1, 1), col=cols) |
The result would be:








