handout

Mathematics 243
R and the Normal Model
R has several functions that we can use to work with the normal model.
function (& parameters)
explanation
dnorm(x,mean,sd)
returns the value of the density function where µ = mean
and σ = sd.
pnorm(q,mean,sd)
returns P (X ≤ q) (the cdf).
rnorm(n,mean,sd)
returns n numbers drawn randomly and independently
from this distribution
qnorm(p,mean,sd)
returns x such that P (X ≤ x) = p.
Example: Suppose that the lifetime of a certain kind of lightbulb can be modeled by a normal model with µ = 1400
hrs and σ = 200. The following functions compute some probabilities related to these lightbulbs.
> pnorm(1800,1400,200)
[1] 0.9772499
> 1-pnorm(1800,1400,200)
[1] 0.02275013
> qnorm(.1,1400,200)
[1] 1143.69
> pnorm(1550,1400,200)-pnorm(1350,1400,200)
[1] 0.372079
The following graph illustrates the relationship between the functions pnorm() and qnorm(). Sketching a graph is
usually the right way to figure out what function to use. The graph illustrates
pnorm(1350,1400,200)=.4013
qnorm(.4013,1400,200)=1350.
0.0010
p
0.0000
y
0.0020
p=pnorm(q) q=qnorm(p)
800
1200 q
1600
Hours
2000