# Practice 7 Working with the Normal Distribution

## 7.1 Directions

In this practice exercise, you will work with the normal distributionin R.

## 7.2 A closer look at the code

In this practice, you will learn about the pnorm() and qnorm commands.

### 7.2.1 Let’s learn to use the pnorm() command

The r code window below will calculate and plot the probability that a normally distributed random variable is less than value. You can change the mean, standard deviation, and value.

Experiment with the settings of mean, standard deviation, and value.

You can get help on any command in R by typing ? in font of the name of the command. Do so in the R code window below.

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiI/cG5vcm0ifQ==

The pnorm() command has four arguments that we need to be concerned about.

• q which holds the value to find the probability of being less than or greater than
• mean which holds the mean of the normal distribution
• sd which holds the standard deviation of the normal distribution
• lower.tail which is set to true for a less than calculation or false for a greater than calculation.

Here are a few examples from the voice thread.

# P(X <=  70) X ~ N(75,5)
pnorm(q=70, mean=75, sd=5, lower.tail=T)
## [1] 0.1586553
# P(X >= 85) X ~ N(75,5)
pnorm(q=85, mean=75, sd=5, lower.tail=F)
## [1] 0.02275013
# P(Z >= 1) where Z ~ N(0,1)
pnorm(q=1, mean=0, sd=1, lower.tail=F)
## [1] 0.1586553

### 7.2.2 Let’s learn to use the qnorm() command

The r code window below will calculate a value, X, such that the probability of drawing a value less than or equal to X is the probability you specify. Then the probability density function is plotted. You can change the mean, standard deviation, and value.

Experiment with the settings of mean, standard deviation, and value.

eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6IiMgRHJhd3MgdGhlIHBsb3RcblxuZHJhdy5ub3JtYWwucGRmIDwtIGZ1bmN0aW9uKG1lYW4sc3RhbmRhcmQuZGV2aWF0aW9uLHByb2JhYmlsaXR5KSB7XG4gIHByb2IgPC0gcHJvYmFiaWxpdHlcbiAgdmFsdWUgPC0gcW5vcm0ocCA9IHByb2IsIG1lYW4gPSBtZWFuLCBzZCA9IHN0YW5kYXJkLmRldmlhdGlvbiwgbG93ZXIudGFpbCA9IFQpXG4gIHBsb3QudGl0bGUgPC0gcGFzdGUoZm9ybWF0KHZhbHVlLCBkaWdpdHM9MiksXCIgaGFzIGEgbG93ZXIgdGFpbCBwcm9iYWJpbGl0eSA9IFwiLGZvcm1hdChwcm9iLCBkaWdpdHM9MikpXG4gIHg9c2VxKG1lYW4tKHN0YW5kYXJkLmRldmlhdGlvbio0KSxtZWFuKyhzdGFuZGFyZC5kZXZpYXRpb24qNCksbGVuZ3RoPTIwMClcbiAgeT1kbm9ybSh4LCBtZWFuID0gbWVhbiwgc2QgPSBzdGFuZGFyZC5kZXZpYXRpb24pXG4gIHBsb3QoeCx5LHR5cGU9XCJsXCIsIGx3ZD0yLCBjb2w9XCJibHVlXCIsIG1haW4gPSBwbG90LnRpdGxlKVxuICB4PXNlcShtZWFuLShzdGFuZGFyZC5kZXZpYXRpb24qNCksdmFsdWUsbGVuZ3RoPTIwMClcbiAgeT1kbm9ybSh4LCBtZWFuID0gbWVhbiwgc2QgPSBzdGFuZGFyZC5kZXZpYXRpb24pXG4gIGFibGluZSh2PW1lYW4pXG4gIHBvbHlnb24oYyhtZWFuLShzdGFuZGFyZC5kZXZpYXRpb24qNCkseCx2YWx1ZSksYygwLHksMCksY29sPVwiZ3JheVwiKVxufSIsInNhbXBsZSI6ImRyYXcubm9ybWFsLnBkZihtZWFuID0gNzUsXG4gICAgICAgICAgICAgICAgc3RhbmRhcmQuZGV2aWF0aW9uID0gNSxcbiAgICAgICAgICAgICAgICBwcm9iYWJpbGl0eSA9IDAuMDVcbiAgICAgICAgICAgICAgICApIn0=

The qnorm() command has four arguments that we need to be concerned about.

• p which holds the value for which you wish to find a probability.
• mean which holds the mean of the normal distribution
• sd which holds the standard deviation of the normal distribution
• lower.tail which is set to true for a less than calculation or false for a greater than calculation.

Here is an examples from the voice thread.

# Find the value of Z such that P(X <= Z) = 25% where x ~ N(75,5)
qnorm(p=0.25, mean=75, sd=5, lower.tail=T)
## [1] 71.62755

## 7.3 R code used in the VoiceThread

# P(X <= 70) X ~ N(75,5)
pnorm(q=70, mean=75, sd=5, lower.tail=T)

# P(X >= 85) X ~ N(75,5)
pnorm(q=85, mean=75, sd=5, lower.tail=F)

# P(Z >= 1) where Z ~ N(0,1)
pnorm(q=1, mean=0, sd=1, lower.tail=F)

# Find the value of X such that P(X <= 70) = 25%  where X ~ N(75,5)
qnorm(p=0.25, mean=75, sd=5, lower.tail=T)

## 7.4 Now you try

Use R to complete the following activities (this is just for practice you do not need to turn anything in).

1. Find the value of probability that Z is greater than 1 where Z ~ N(0,1).
2. Find the value of X such that P(Z <= X) = 25% where X ~ N(75,5).
eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiIjIFF1ZXN0aW9uIDFcblxuXG4jIFF1ZXN0aW9uIDIiLCJzb2x1dGlvbiI6IiMgUXVlc3Rpb24gMVxucG5vcm0ocT0xLCBtZWFuPTAsIHNkPTEsIGxvd2VyLnRhaWw9RilcblxuIyBRdWVzdGlvbiAyXG5xbm9ybShwPTAuMjUsIG1lYW49NzUsIHNkPTUsIGxvd2VyLnRhaWw9VCkifQ==