Using Base R

Finding the Area Under a Normal Curve to the Left of Some Value

To compute the area under the curve to the left of some value x in R, use the following command:

pnorm(x, \(\mu\),\(\sigma\))

Let’s find the area under the normal curve to the left of 120 where \(\mu\) = 100 and \(\sigma\) = 15.

pnorm(120,100,15)
## [1] 0.9087888

So, P(X < 120) = 0.9088.

If you want the area under the curve to the right of some value x, find the area under the curve to the left, and then subtract this result from 1.

Let’s find the area under the normal curve to the left of 120 where \(\mu\) = 100 and \(\sigma\) = 15.

1 - pnorm(120,100,15)
## [1] 0.09121122

So, P(X > 120) = 0.0912.

Finding the Area Under a Normal Curve between Two Values

To compute the area under a normal curve between two values, \(x_1\) and \(x_2\) where \(x_1\) < \(x_2\), use the following command:

pnorm(\(x_2\),\(\mu\),\(\sigma\)) - pnorm(\(x_1\),\(\mu\),\(\sigma\))

Let’s find the area under the normal curve between 90 and 120 where \(\mu\) = 100 and \(\sigma\) = 15.

pnorm(120,100,15)-pnorm(90,100,15)
## [1] 0.6562962

So, P(90 \(\leq\) X \(\leq\) 120) = 0.6563.

Using Mosaic

Finding the Area Under a Normal Curve to the Left of Some Value

install.packages("mosaic")

To compute the area under the curve to the left of some value x using the Mosaic package, use the following command:

xpnorm(x, \(\mu\),\(\sigma\))

The advantage of the Mosaic package is that a graph of the normal curve with the area desired shaded is provided.

Let’s find the area under the normal curve to the right of 120 where \(\mu\) = 100 and \(\sigma\) = 15.

library(mosaic)
xpnorm(120,mean=100,sd=15)

## [1] 0.9087888

So, P(X < 120) = 0.9088.

If you want the area under the curve to the right of some value x, find the area under the curve to the left, and then subtract this result from 1.

Let’s find the area under the normal curve to the right of 120 where \(\mu\) = 100 and \(\sigma\) = 15.

1 - xpnorm(120,100,15)
## 
## If X ~ N(100, 15), then
##  P(X <= 120) = P(Z <= 1.333) = 0.9088
##  P(X >  120) = P(Z >  1.333) = 0.09121
## 

## [1] 0.09121122

So, P(X > 120) = 0.0912.

Finding the Area Under a Normal Curve between Two Values

To compute the area under a normal curve between two values, \(x_1\) and \(x_2\) where \(x_1\) < \(x_2\), use the following command:

xpnorm(\(x_2\),\(\mu\),\(\sigma\)) - pnorm(\(x_1\),\(\mu\),\(\sigma\))

Let’s find the area under the normal curve between 90 and 120 where \(\mu\) = 100 and \(\sigma\) = 15.

xpnorm(120,100,15) - xpnorm(90,100,15)
## 
## If X ~ N(100, 15), then
##  P(X <= 120) = P(Z <= 1.333) = 0.9088
##  P(X >  120) = P(Z >  1.333) = 0.09121
## 
## If X ~ N(100, 15), then
##  P(X <= 90) = P(Z <= -0.6667) = 0.2525
##  P(X >  90) = P(Z >  -0.6667) = 0.7475
## 

## [1] 0.6562962

So, P(90 \(\leq\) X \(\leq\) 120) = 0.6563.