Recall that a normal distribution with mean $\mu$ and standard deviation $\sigma$ is one characterized by the normal density function: $$f(x) = \frac{1}{\sigma \sqrt{2\pi}} e^{\frac{-(x-\mu)^2}{2\sigma^2}}$$ The value of this function is given by the R function

`dnorm`

__Usage__`dnorm(x, mean=μ, sd=σ)`

__Example__

The height at $x=13$ of the normal curve with mean 10 and standard deviation 7 is given by

> dnorm(13,10,7) [1] 0.05199096

To find the probability that a normally distributed random variable with mean $\mu$ and standard deviation $\sigma$ results in a value less than $x$ (i.e. the area under the normal curve to the left of $x$.) is given by the following R function:

`pnorm`

__Usage__`pnorm(x, mean=μ, sd=σ)`

__Examples__

Suppose the manufacturer of a certain type of snack knows that the total weight of the snack packet they sell is normally distributed with a mean of $80.2$ grams and a standard deviation of $1.1$ grams. What is the probability that a selected packet is less than $78$ grams?

> pnorm(78,80.2,1.1) [1] 0.02275013Under the same assumptions, what is the probability that a selected packet has a weight within 2 standard deviations of the mean weight?

> pnorm(82.4,80.2,1.1) - pnorm(78,80.2,1.1) [1] 0.9544997

Notice, in the last example, we find the area under the normal curve between $x=a$ and $x=b$ by finding a difference of two left-tailed areas.

R also provides the following function that gives the $x$ value for which a normally distributed random variable with mean $\mu$ and standard deviation $\sigma$ will produce an outcome less than $x$ with some given probability of $p$. Said another way, this function gives the $x$ value where there is an area of $p$ to the left of $x$ and under the related normal curve.

`qnorm`

__Usage__`qnorm(p,mean=μ,sd=σ)`

__Example__

A math contest author knows that the length of time taken by students to complete a certain section of math questions is normally distributed with a mean of 17 minutes and standard deviation of 4.5 minutes. $90\%$ of students should have completed the section of questions in how many minutes?

> qnorm(0.90,17,4.5) [1] 22.76698Under the same assumptions, how long should the middle $50\%$ of students take to complete this section?

> qnorm(0.75,17,4.5) [1] 20.0352 > qnorm(0.25,17,4.5) [1] 13.9648 # ...so roughly between 14 and 20 minutes

Lastly, R also has a function that lets you simulate random variables that follow a Normal distribution:

`rnorm`

__Usage__`rnorm(n, mean=μ, sd=σ)`

Note: $n$ represents the number of realizations of your random variable you wish to produce.

__Examples__

Suppose the error in a particular model follows a normal distribution with mean $\mu = 5$ and standard deviation $\sigma = 1$. Simulate the errors seen in 15 applications of the model in question.

> rnorm(15, mean=5, sd=1) [1] 5.625824 6.438588 6.642417 3.537867 4.853430 [6] 4.405501 5.684504 6.041753 4.434506 5.550997 [11] 5.095519 5.188711 5.077366 5.102386 4.247265