R Language Distribution Functions Normal distribution


Let's use *norm as an example. From the documentation:

dnorm(x, mean = 0, sd = 1, log = FALSE)
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
rnorm(n, mean = 0, sd = 1)

So if I wanted to know the value of a standard normal distribution at 0, I would do


Which gives us 0.3989423, a reasonable answer.

In the same way pnorm(0) gives .5. Again, this makes sense, because half of the distribution is to the left of 0.

qnorm will essentially do the opposite of pnorm. qnorm(.5) gives 0.

Finally, there's the rnorm function:


Will generate 10 samples from standard normal.

If you want to change the parameters of a given distribution, simply change them like so

rnorm(10, mean=4, sd= 3)