Homework 3

Martin luo

2023 10 17

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?

plot(x    = 0:20,
     y    = dbinom(x    = 0:20,
                   size = 20,
                   prob = .5
     ),
     type = 'h',
     main = 'Binomial Distribution (n=20, p=0.5)',
     ylab = 'Probability prefers red',
     xlab = '# Buyers',
     lwd  = 3
)

dbinom(x = 9:12, size = 20, prob = .5)
## [1] 0.1601791 0.1761971 0.1601791 0.1201344
sum(dbinom(x = 9:12, size = 20, prob = .5))
## [1] 0.6166897
round(x = sum(dbinom(x = 9:12, size = 20, prob = .5)), digits = 4)
## [1] 0.6167

2.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(total_probability, 4)

plot(x    = 0:13, 
     y    = dbinom(x    = 0:13, 
                   size = 13, 
                   prob = .2
                  ), 
     type = 'h',
     main = 'Binomial Distribution (n=13, p=0.2)',
     ylab = 'Probability',
     xlab = '# Successes',
     lwd  = 3
     )

dbinom(x = 4:5, size = 13, prob = .2)
## [1] 0.15354508 0.06909529
sum(dbinom(x = 4:5, size = 13, prob = .2))
## [1] 0.2226404
round(x = sum(dbinom(x = 4:5, size = 13, prob = .2)),digits = 4)
## [1] 0.2226

3.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?

plot(x    = 0:10,
     y    = dpois(x = 0:10,
                  lambda = 4.2
                ),
     type = 'h',
     main = 'Poisson Distribution (lambda=4.2)',
     ylab = 'Probability',
     xlab = '# Special Orders',
     lwd  = 3
)

ppois(3, lambda = 4.2)
## [1] 0.3954034
round(x = ppois(3, lambda = 4.2), digits = 4)
## [1] 0.3954

4.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?

plot(x    = 0:3,
     y    = dhyper(x    = 0:3,
                   m = 6,
                   n = 17-6,
                   k = 3
     ),
     type = 'h',
     main = 'Hypergeometric Distribution',
     ylab = 'Probability',
     xlab = '# Bottles',
     lwd  = 3
)

res = sum(dhyper(x = 0:1, m = 6, n = 17-6, k = 3))

round(x = res, digits = 4)
## [1] 0.7279

5.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?

plot(x    = 0:6,
     y    = dhyper(x = 0:6,
                   m = 6,
                   n = 19,
                   k = 6
                ),
     type = 'h',
     main = 'Hypergeometric Distribution (N=25, n=6, S=6)',
     ylab = 'Probability ',
     xlab = '#Dismissed Employees',
     lwd  = 3
)

res <- sum(dhyper(x = 2:6, m = 6, n = 19, k = 6))

round(res, 4)
## [1] 0.4529

6.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_weight <- 800
variance <- 90000
lower_num <- 1040
upper_num <- 1460


lower <- (lower_num - mean_weight) / sqrt(variance)
upper <- (upper_num - mean_weight) / sqrt(variance)


probability <- diff(pnorm(c(lower, upper)))

round(probability ,4)
## [1] 0.198

7.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.

mean_diameter <- 106
sdv <- 4
lower_num <- 103
upper_num <- 111

probability <- diff(pnorm(c((lower_num - mean_diameter) / sdv, (upper_num - mean_diameter) / sdv)), lower.tail = FALSE)

probability <- round(probability, 4)

probability
## [1] 0.6677

8.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_length <- 3.34
sdv <- 0.07
upper <- qnorm(0.97) 
lower <- qnorm(0.03)  

length_upper <- mean_length + upper* sdv
length_lower <- mean_length + lower * sdv

round(length_upper, 2)
## [1] 3.47
round(length_lower, 2)
## [1] 3.21

9.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.

mean_score <- 75.8
sdv <- 8.1
top_percentile <- 0.09 
grade <- qnorm(1 - top_percentile, mean_score, sdv)

round(grade)
## [1] 87

10.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%.

n <- 155  
p <- 0.61  
mean <- n * p
variance <- n * p * (1 - p)


probability <- pnorm(96, mean, sqrt(variance)) -
                                     pnorm(95, mean, sqrt(variance))

round(probability,4)
## [1] 0.0648