This article about R’s rnorm function is part of a series we’re doing about generating random numbers using the R language. Our earlier sets of examples dealt with randomly picking from a list of discrete values and the uniform distributions. The rnorm function offers similar functionality for the normal distribution, which is a commonly requested for scientific and business analysis.

### R and the Standard Normal Distribution

We’re going to start by introducing the rnorm function and then discuss how to use it.

R’s rnorm function takes the parameters of a normal distribution and returns X values as a list. The expected syntax is:

rnorm (n, mean = x, sd = y)

Specifically:

- n – number of observations we want rnorm to return
- mean – mean value of the normal distribution we are using
- sd – standard deviation of the normal distribution we are using

If we wanted to generate value from a **standard normal distribution,** where mean = 0 and the standard deviation is 1, we would code it as:

rnorm(5, mean=0, sd=1) [1] 0.46704102 -0.36129104 -0.07062314 1.40160030 0.16795590

As we can see, this function generates an appropriate looking set of values.

An example of a regular normal distribution:

rnorm(5, mean=20, sd=5) [1] 27.35130 15.00245 16.76702 23.17056 31.29196

Again, using rnorm to generate a set of values from the distribution.

### Using rnorm & The Normal Distribution

The normal distribution is broadly used in the sciences and business. It represents the convergence of the average of a set of samples from a uniform distribution. This is the traditional “bell curve”.

This distribution works in the real world due to the nature of how most processes operate. Most results are affected by several process steps. A widget might cut by saw A. Then saw B. After which, we cut and wrap a set of 20 widgets into a bundle. Perhaps a few widgets may be bumped at different points on the conveyor belt. The final width of a widget is the sum of these little errors.

If we assume each of the “little errors” is uniformly distributed, the sum of these errors will converge on the normal distribution.

So you can use the normal distribution for a wide range of things:

- Stock Market Returns
- Athletic Performance
- Test Scores
- Sports Scores