1. A researcher wishes to conduct a study of the color preferences of new car buyers. Suppose that 50% of this population prefers the color red. If 20 buyers are randomly selected, what is the probability that between 9 and 12 (both inclusive) buyers would prefer red?
n1<-20
p1<-0.5
x1<-9:12
red<-0:n1
probabilities1<-dbinom(red,size=n1,prob=p1)
barplot(probabilities1,names.arg=red, main=paste("Binomial Distribution (n=",n1,", p=",p1,")"),xlab="Number of Buyers Who Prefer Red", ylab="Probability")

q1<-sum(dbinom(x1,size = n1,prob=p1))
round(q1,4)
## [1] 0.6167

The probability that between 9-12 buyers would prefer red is 61.67%.

  1. A quality control inspector has drawn a sample of 13 light bulbs from a recent production lot. Suppose 20% of the bulbs in the lot are defective. What is the probability that less than 6 but more than 3 bulbs from the sample are defective?
    Round your answer to four decimal places.
n2<-13
p2<-0.2
x2<-4:5
defective<-0:n2
probabilities2<-dbinom(defective,size = n2,prob = p2)
barplot(probabilities2,names.arg = defective,main=paste("Binomial Distribution (n=",n2,", p=",p2,")"),xlab="Number of Defective Light Bulbs", ylab="Probability",ylim=c(0,max(probabilities2)*1.1))

q2<-sum(dbinom(x2,size = n2,prob=p2))
round(q2,4)
## [1] 0.2226

The probability that between 3 and 6 bulbs in the sample are defective is 22.26%.

  1. The auto parts department of an automotive dealership sends out a mean of 4.2 special orders daily. What is the probability that, for any day, the number of special orders sent out will be no more than 3?
    Round your answer to four decimal places.
q3<-3
lambda3<-4.2
###Boundary so we can clearly see on the graph
max_x<-10
x_values<-0:max_x
probabilities3<-dpois(x_values,lambda = lambda3)
barplot(probabilities3,names.arg=x_values,main=paste("Poisson Distribution (lambda=",lambda3,")"),xlab="Number of Special Orders", ylab="Probability",ylim=c(0,max(probabilities3)+0.05))

round(ppois(q3,lambda = lambda3),4)
## [1] 0.3954

The probability that the number of special orders sent out is not more than 3 is 39.54%.

  1. A pharmacist receives a shipment of 17 bottles of a drug and has 3 of the bottles tested. If 6 of the 17 bottles are contaminated, what is the probability that less than 2 of the tested bottles are contaminated?
    Round your answer to four decimal places.
#### m = number of successes in population, n = number of failures in population, k = number of drawings in sample, x= number of successes in sample

###contamination = success
m4<-6
n4<-17-6
k4<-3
###probability that 0 or 1 bottles in sample would be contaminated
q4<-1
round(phyper(q4,m4,n4,k4,lower.tail = TRUE),4)
## [1] 0.7279

The probability that less than 2 of the tested bottles are contaminated is 72.79%.

  1. A town recently dismissed 6 employees in order to meet their new budget reductions. The town had 6 employees over 50 years of age and 19 under 50. If the dismissed employees were selected at random, what is the probability that more than 1 employee was over 50?
    Round your answer to four decimal places.
###successes = employees over 50
m5<-6
n5<-19
k5<-6
x5<-1
round(phyper(x5,m5,n5,k5,lower.tail = FALSE),4)
## [1] 0.4529

The probability that more than 1 employee was over 50 is 45.29%.

  1. 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.
    Round your answer to four decimal places.
mean6<-800
###standard deviation is the square root of the variance
sd6<-sqrt(90000)
curve(dnorm(x,mean = mean6,sd = sd6),from= 0, to = 2000, main="Distribution of Steer Weights",xlab = "Weight (lbs)", ylab = "Probability Density")

probability6<-pnorm(1460,mean = mean6, sd = sd6,lower.tail = TRUE)-pnorm(1040,mean = mean6, sd = sd6, lower.tail = TRUE)
round(probability6,4)
## [1] 0.198

The probability that a randomly selectedsteer is between 1040 and 1460 pounds is 19.80%.

  1. 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.
    Round your answer to four decimal places.
mean7<-106
sd7<-4
curve(dnorm(x,mean = mean7,sd=sd7),from = 0, to = 200, main="Distribution of Ball Bearing Diameters",xlab="Diameters (in mm)",ylab="Probability Density")

probability7<-pnorm(111,mean = mean7,sd=sd7,lower.tail = TRUE)-pnorm(103,mean = mean7, sd=sd7, lower.tail = TRUE)
round(probability7, 4)
## [1] 0.6677

The probability that the diameter of the selected bearing is between 103 and 111 mm is 66.77%.

  1. 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.
    Round your answer to the nearest hundredth (2 decimal places), if necessary.
    You will have to use the quantile function1, qnorm() here. In fact, we have seen a little bit of quintiles already when we talked about median and boxplots.
mean8<-3.34
sd8<-0.07
curve(dnorm(x,mean = mean8,sd=sd8),from =2, to = 5,main="Length of Nails",xlab = "Length (in cm)",ylab = "Probability Density")

top<-0.97
bottom<-1-top
probability_top<-qnorm(top,mean = mean8,sd=sd8)
probability_bottom<-qnorm(bottom,mean=mean8,sd=sd8)
round(probability_top,2)
## [1] 3.47
round(probability_bottom,2)
## [1] 3.21

The minimum length for the top 3% is 3.47cm. The maximum length for the bottom 3% is 3.21cm.

  1. A psychology professor assigns letter grades on a test according to the following scheme.
    A: Top 9% of scores
    B: Scores below the top 9% and above the bottom 63%
    C: Scores below the top 37% and above the bottom 17%
    D: Scores below the top 83% and above the bottom 8%
    F: Bottom 8% of scores
    Scores on the test are normally distributed with a mean of 75.8 and a standard deviation of 8.1. Find the minimum score required for an A grade.
    Round your answer to the nearest whole number, if necessary.
mean9<-75.8
sd9<-8.1
curve(dnorm(x,mean=mean9,sd=sd9),from = 45, to = 100,main="Psychology Grades", xlab = "Grades (%)",ylab="Probability Density")

A_Grade<-1-.09
round(qnorm(A_Grade,mean = mean9,sd=sd9),0)
## [1] 87

The minimum score required for an A grade is 87%.

  1. Consider the probability that exactly 96 out of 155 computers will not crash in a day. Assume the probability that a given computer will not crash in a day is 61%. Approximate the (binomial) probability using the normal distribution.
    Round your answer to four decimal places.
n10<-155
p10<-0.61
mean10<-n10*p10
###sd formula: n*p*(1-p)
sd10<-sqrt(n10*p10*(1-p10))
x10<-96
round(dnorm(x10,mean = mean10,sd=sd10),4)
## [1] 0.0639
round(dbinom(x10,size = n10,prob = p10),4)
## [1] 0.064
probabilities10<-dbinom(0:n10,size = n10,prob = p10)
barplot(probabilities10,names.arg=0:n10, main = "Computer Crash Probability (Binomial Distribution)",xlab = "Number of Computers", ylab = "Probability")

curve(dnorm(x,mean=mean10,sd=sd10),from = 10, to = 155,main="Computer Crash Probability", xlab = "Number of Computers (Normal Distribution)",ylab = "Probability Density")

The probability that exactly 96 computers would not crash is 6.39% using a normal distribution and 6.40% using a binomial distribution.