Rweb in Stat 3011 Home Page Stat 3011 Home Page About the Rweb in Stat 3011 Web Pages
The Rweb function that calculates what our textbook denotes
P(z < z*), that is, the area under the standard normal curve
to the left of the point z*, is pnorm
. For any
real number z the Rweb expression pnorm(z)
calculates the area to the left of z, for example,
pnorm(2.123)calculates the area (0.983123) to the left of 2.123, that is, P(z < 2.123).
To do more complicated areas, one needs to use the addition rules and
complement rules together with the pnorm
function. For example,
1 - pnorm(2.123)calculates the area (0.01687693) to the right of 2.123, that is, P(z > 2.123), and
pnorm(2.123) - pnorm(0.456)calculates the area (0.3073181) between 0.456 and 2.123, that is, P(0.456 < z < 2.123).
Rweb also has a function that does "backward" or "inverse" look-up. The "forward" problem is to find the probability p to the left of a point z. The "backward" problem is to find the point z that has probability p to the left it.
The Rweb function that does backward lookup is qnorm
.
Question: What is the point z such that 95% of the area under the
standard normal curve is to the left of z? Answer:
qnorm(0.95)which is 1.644854.
The "q" in qnorm
comes from the word "quantile."
If
p = pnorm(z)then
z = qnorm(p)and z is called the p-th quantile of the standard normal distribution. This shows that
pnorm
and
qnorm
are what are called "inverse functions" in higher
mathematics.
A special case of quantiles are percentiles that we learned about in
Chapter 3 of our textbook. The 0.95 quantile is the 95th percentile,
and so forth. (The only reason for the word "quantile" instead of
"percentile" is that it applies when there are more than two significant
figures. You can say 0.1875 quantile, but you generally don't say 18.75th
percentile.) This tells us that qnorm
is useful for looking
up percentiles of the standard normal distribution: qnorm(0.35)
is the 35th percentile, and so forth.
Of course, the complement rule and the addition rule can also be used
in "backward" problems. But be careful! It's the argument
of qnorm
, not the value, that's the probability. So
qnorm(1 - p)looks up the point z having probability p to the right of z. But
1 - qnorm(p)is usually rubbish, because
qnorm(p)
is not
a probability, hence it's not a thing to which the complement rule applies.
Problems involving general normal distributions are hard using table look-up,
because they all must be translated to and from equivalent problems using
the standard normal distribution. With the computer all of these problems
become much easier, because pnorm
and qnorm
also
do general normal distributions using their optional second and third
arguments, which specify the mean and standard deviation of the normal
distribution for which probabilities or quantiles are being calculated.
Question: If x is normal with mean 2 and standard deviation 3.4, what is P(x > 0). Answer:
1 - pnorm(0, 2, 3.4)The first argument gives the x value we want to look up. The second and third give the mean and s. d., respectively.
Question: If x is normal with mean 100 and variance 600, what is P(90 < x < 115). Answer:
pnorm(110, 100, sqrt(600)) - pnorm(90, 100, sqrt(600))Note that the s. d. is
sqrt(600)
. The third argument is the
standard deviation, not the variance.
The pattern used in both of these questions should be familiar. These are just like the examples for the standard normal distribution. The addition and complement rules are used in exactly the same way.
Question: What is the 95th percentile of a normal random variables with 3 and standard deviation 4? Answer:
qnorm(0.95, 3, 4)
Again, just like a standard normal problem, except for the two optional
arguments of qnorm
.