- dnorm(x, mean, sd) -- The height of a normal density
with μ and σ specified by the mean and
sd arguments.
Example:
draw a plot of the normal density of SAT scores, where μ=1500 and σ=300.
Use seq(0, 2500, 1) for the x-values. Set the title of the plot (main argument)
to "Density of SAT Scores". Answer:
> x <- seq(0, 2500, 10)
> y <- dnorm(x, mean=1500, sd=300)
> plot(x, y, type="l", main="Density of SAT Scores")
- pnorm(x, mean, sd) -- The area under the normal
density above the interval (-∞, x].
Example: if μ=1500 and σ=300 for
SAT scores, find the proportion of scores that are greater than 1950. of Answer:
> pnorm(1950, 1500, 300)
[1] 0.9331928
However, we don't want area (-∞, 1950], we want area (1950, ∞) = 1 -
area (-∞, 1950]. The answer we want is
> 1 - pnorm(1950, 1500, 300)
[1] 0.0668072
- qnorm(p, mean, sd) -- The p quantile for the normal
density.
Example: If μ=1500 and σ=300 for SAT scores, what is the 0.95
quantile or 95th percentile for SAT scores?
Answer:
> qnorm(0.95, 1500, 300)
[1] 1993.456
- rnorm(n, mean, sd) -- Generate n normally
distributed random numbers with the specified mean and SD.
Example: Generate 100 normally distributed random values with mean=1500 and
sd=300. Then create the histogram, the box plot, and the plot of the x-values vs
observation number.
> x <- 1:100
> y <- rnorm(x, 1500, 300)
> hist(y)
> boxplot(y)
> plot(x, y)