R Normal Distribution
In random collections of data from independent sources, it is commonly seen that the distribution of data is normal. It means that if we plot a graph with the value of the variable in the horizontal axis and counting the values in the vertical axis, then we get a bell shape curve. The curve center represents the mean of the data set. In the graph, fifty percent of the value is located to the left of the mean. And the other fifty percent to the right of the graph. This is referred to as the normal distribution.
R allows us to generate normal distribution by providing the following functions:
These function can have the following parameters:
Let's start understanding how these functions are used with the help of the examples.
The dnorm() function of R calculates the height of the probability distribution at each point for a given mean and standard deviation. The probability density of the normal distribution is:
The dnorm() function is also known as "Cumulative Distribution Function". This function calculates the probability of a normally distributed random numbers, which is less than the value of a given number. The cumulative distribution is as follows:
The qnorm() function takes the probability value as an input and calculates a number whose cumulative value matches with the probability value. The cumulative distribution function and the inverse cumulative distribution function are related by
The rnorm() function is used for generating normally distributed random numbers. This function generates random numbers by taking the sample size as an input. Let's see an example in which we draw a histogram for showing the distribution of the generated numbers.