### Normal Distribution

A random variable $$X$$ is said to have normal distribution if it symmetiric and has bell shape with only one peak. Mathematically, it is represented by the following function.

$$f(x)=\frac{1}{\sigma \sqrt{2 \pi}} \exp ^{-\frac{1}{2} \left( \frac{x-\mu}{\sigma }\right)^{2}}$$

where $$-\infty < \mu < \infty$$ and $$0< \sigma < \infty$$

Example :

Here we are plotting a normal distribution function with $$\mu$$ =0 and $$\sigma = 1.$$

x<- seq(-4,4,length=200)
y<- 1/sqrt(2*pi)*exp(-x^2/2)
plot(x,y,type="l",lwd=2,col="red")

We can plot the same normal distribution function by using default funchtion in R.

 x=seq(-4,4,length=200)
y=dnorm(x,mean=0,sd=1)
plot(x,y,type="l",lwd=2,col="red")

How about changing the standard deviation ? Pay attention on the shape of the curve, the normal curve gets flatter and more spread when standard deviation increases. Basically, standard deviation controls the shape of the curve. Therefore, standard deviation is also called “shape parameter.”

x=seq(-8,8,length=500)
y1=dnorm(x,mean=0,sd=1)
plot(x,y1, type="l",lwd=2,col="red", ylab="density")
y2=dnorm(x,mean=0,sd=2)
lines(x,y2,type="l",lwd=2,col="blue")

y3=dnorm(x,mean=0,sd=3)
lines(x,y3,type="l",lwd=2,col="green")

y4=dnorm(x,mean=0,sd=4)
lines(x,y4,type="l",lwd=2,col="black")

y5=dnorm(x,mean=0,sd=5)
lines(x,y5,type="l",lwd=2,col="yellow")
legend('topright', legend=c("mean=0,sd=1", "mean=0,sd=2", "mean=0,sd=3", "mean=0,sd=4", "mean=0,sd=5"),
col=c("red","blue" ,"green","black","yellow"), pch=16)