Normal Distribution in R

Normal Distribution is a probability function used in statistics that tells about how the data values are distributed. It is the most important probability distribution function used in statistics because of its advantages in real case scenarios. For example, the height of the population, shoe size, IQ level, rolling a dice, and many more.

It is generally observed that data distribution is normal when there is a random collection of data from independent sources. The graph produced after plotting the value of the variable on x-axis and count of the value on y-axis is bell-shaped curve graph. The graph signifies that the peak point is the mean of the data set and half of the values of data set lie on the left side of the mean and other half lies on the right part of the mean telling about the distribution of the values. The graph is symmetric distribution. 

Normal distribution is a common statistical distribution used to describe continuous random variables in which the probability of any value occurring is proportional to the distance from the mean of the distribution. It is also known as Gaussian distribution, and it is symmetric around its mean.

R is a powerful tool for statistical analysis and has built-in functions to work with normal distributions. To work with normal distribution in R, one needs to use the functions "dnorm", "pnorm", "qnorm", and "rnorm".

The "dnorm" function returns the probability density function of the normal distribution. It takes in the value, mean, and standard deviation as arguments. The "pnorm" function returns the cumulative distribution function of the normal distribution, which represents the probability of getting a value less than or equal to a given value. The "qnorm" function returns the inverse cumulative distribution function, which provides the value corresponding to a given probability. Finally, the "rnorm" function generates random numbers from the normal distribution with a specified mean and standard deviation.

To visualize a normal distribution in R, one can use the "ggplot2" package. This package provides various functions to plot histograms, density plots, and other visualizations. For example, to plot a histogram of a normal distribution with a mean of 0 and a standard deviation of 1, one can use the following code: 

 

library(ggplot2)
data <- data.frame(x=rnorm(10000, mean=0, sd=1))
ggplot(data, aes(x)) + geom_histogram(binwidth=0.1, fill="blue", color="white")

This code generates a histogram plot with a bin width of 0.1 and blue fill color.

Submit Your Programming Assignment Details