rnorm in r
The function rnorm
in R is used to generate random numbers from a normal distribution. It takes the following arguments:
n
: This specifies the number of random numbers to generate.mean
: This specifies the mean of the normal distribution.sd
: This specifies the standard deviation of the normal distribution.
Here is an example of how to use the rnorm
function in R:
# Generate 100 random numbers from a normal distribution with mean 0 and standard deviation 1
random_numbers <- rnorm(n = 100, mean = 0, sd = 1)
In this example, we are generating 100 random numbers from a normal distribution with a mean of 0 and a standard deviation of 1. The generated random numbers are stored in the variable random_numbers
.