#The weights of steers in a herd are distributed normally.  The variance is 90,000 and the  
#mean steer weight is 800 lbs.  Find the probability that the weight of a randomly  
#selected steer is between 1040 and 1460 lbs.  

#mean=800
#sd=sqrt(90000)
#sd

PW<-pnorm(1040, mean=800, sd=sqrt(90000), lower.tail = FALSE) -
  pnorm(1460, mean=800, sd=sqrt(90000), lower.tail = TRUE)
#ggplot(mapping = aes(Weigh = PW)) + stat_qq_point(size = 2)
PW
## [1] -0.7742412
qqnorm(PW, 
           ylab="Weigh", 
            xlab="Herd", 
            main="weights of steers in a herd") 
qqline(PW)

PW
## [1] -0.7742412
RPW<-round(PW,digits = 4)
RPW
## [1] -0.7742
#-  Above code is mine

#I am now trying with your (AS) solution

#x<-c(1040,1460)

sum(dnorm(x=1040:1460,mean=800,sd=300))
## [1] 0.198494
pnorm(q=1460, mean=800, sd=sqrt(90000)) -
  pnorm(q=1040, mean=800, sd=sqrt(90000))
## [1] 0.197952
#continous distribution, not discrete.

pnorm(q=1040, mean=800, sd=sqrt(90000), lower.tail = FALSE) -
  pnorm(q=1460, mean=800, sd=sqrt(90000), lower.tail = FALSE)
## [1] 0.197952
round(x=(pnorm(q=1460, mean=800, sd=sqrt(90000)) -
  pnorm(q=1040, mean=800, sd=sqrt(90000))),digits=4)
## [1] 0.198
?seq()
## starting httpd help server ... done
x <- seq(from   = -4, 
         to     = 4, 
         length = 1000) * 300 + 800

#create a vector of values that shows the height of the probability distribution for each value in x
y <- dnorm(x = x,    # argument = vector x created by seq() function
           mean = 800, 
           sd = 300
)

#plot normal distribution with customized x-axis labels
plot(x = x,
     y = y, 
     type = "l", 
     lwd = 2, 
     axes = FALSE, 
     xlab = "", 
     ylab = ""
)

sd_axis_bounds <- 5
axis_bounds <- seq(from = -sd_axis_bounds *300 + 800,
                   to =  sd_axis_bounds * 300 + 800,
                   by = 300)
axis(side = 1, at = axis_bounds, pos = 0)

#The diameters of ball bearings are distributed normally.  The mean diameter is 106  
#millimeters and the standard deviation is 4 millimeters.  Find the probability that the  
#diameter of a selected bearing is between 103 and 111 millimeters.  


#mean=106
#sd=4
#P(X) between 103 and 111
data<-103:111
data
## [1] 103 104 105 106 107 108 109 110 111
dnorm(x=data,mean=106,sd=4)
## [1] 0.07528436 0.08801633 0.09666703 0.09973557 0.09666703 0.08801633 0.07528436
## [8] 0.06049268 0.04566227
sum(dnorm(x=data,mean=106,sd=4))                     
## [1] 0.725826
PW<-pnorm(q=111, mean=106, sd=4)
- pnorm(q=103, mean=106, sd=4)
## [1] -0.2266274
PW
## [1] 0.8943502
??diff
diff(x=pnorm(c(103,111),mean=106,sd=4))
## [1] 0.6677229
pnorm(q=103, mean=106, sd=4,lower.tail = F)
## [1] 0.7733726
- pnorm(q=111, mean=106, sd=4,lower.tail = F)
## [1] -0.1056498
#The lengths of nails produced in a factory are normally distributed with a mean of 3.34   
#centimeters and a standard deviation of 0.07 centimeters.  Find the two lengths that  
#separate the top 3% and the bottom 3%.  These lengths could serve as limits used to  
#identify which nails should be rejected.   

mean=3.34
sd=0.07

qnorm(p=.03,mean=3.34,sd=0.07)
## [1] 3.208344
qnorm(p=0.97,mean=3.34,sd=0.07)
## [1] 3.471656
round(x=c(qnorm(p=0.03,mean=3.34,sd=0.07),qnorm(p=0.97,mean=3.34,sd=0.07)),digits=2)
## [1] 3.21 3.47
# bottom 3% and the top 3%.

qnorm(p=c(.03,.5,0.97),mean=3.34,sd=.07)
## [1] 3.208344 3.340000 3.471656
x <- seq(from = -4, to = 4, length = 1000) * .07 +3.34

#create a vector of values that shows the height of the probability distribution
#for each value in x
y <- dnorm(x, mean=3.34, sd=.7)

#plot normal distribution with customized x-axis labels
plot(x,y, type = "l", lwd = 2, axes = FALSE, xlab = "", ylab = "")
sd_axis_bounds = 5
axis_bounds <- seq(from = -sd_axis_bounds *.07 + 3.34,
                   to =  sd_axis_bounds *.07 + 3.34,
                   by = .07)
axis(side = 1, at = axis_bounds, pos = 0)