rnorm()

The function rnorm() enables us to generate normally distributed random numbers.

rnorm(n, mean = 0, sd = 1)

where n is the number of random numbers we want to generate, mean is the mean of the normal distribution and sd is the standard deviation.

A function call to get 1000 normal distribution random numbers with mean 10 and standard deviation 2 would be

rnorm(n = 1000, mean = 10, sd = 2)

Note: Besides random number generation R provides probability distribution functions, density functions and quantile functions for most of the common distributions. The following naming scheme is used:

  • pdist for probability distribution functions,
  • ddist for density functions,
  • qdist for quantile functions,
  • rdist for random number generation,

where dist indicates the desired distribution.

An overview over the base R functionality and distributions provided by additional CRAN packages can be found here.