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?

library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
n <- 20
x <- 9:12
p <- .5

binom <- dbinom(0:n, n, p)

df <- data.frame(x = c(0:n), y = binom)

round(sum(binom[10:13]),4)
## [1] 0.6167
ggplot(df, aes(x = 0:n, y = binom)) + geom_col(fill = "light blue", color = "black") + labs(title = "Binomial Distribution of Car Buyers Who Prefers Red", x = "Number of Buyers", y = "Probability") + geom_line(color = "red", linewidth = 0.75)

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?

n <- 13
x <- 4:5
p <- .2

binom <- dbinom(0:n, n, p)

df <- data.frame(x = c(0:n), y = binom)

round(sum(binom[5:6]),4)
## [1] 0.2226
ggplot(df, aes(x = 0:n, y = binom)) + geom_col(fill = "light blue", color = "black") + labs(title = "Binomial Distribution of Defective Light Bulbs", x = "Number of Light Bulbs", y = "Probability") + geom_line(color = "red", linewidth = 0.75)

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?

lambda <- 4.2
k <- 0:10

distribution <- dpois(k, lambda)

df <- data.frame(x = c(0:k), y = distribution)
## Warning in 0:k: numerical expression has 11 elements: only the first used
distribution
##  [1] 0.014995577 0.062981423 0.132260988 0.185165383 0.194423652 0.163315867
##  [7] 0.114321107 0.068592664 0.036011149 0.016805203 0.007058185
round(sum(distribution[1:4]), 4)
## [1] 0.3954
ggplot(df, aes(x = k, y = distribution)) + geom_col(color = "black", fill = "light green") + labs(title = "Poisson Distribution of Special Orders", x = "Number of Special Orders", y = "Probability") + geom_line(color = "blue", linewidth = 0.75)

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?

x <- 0:1 
m <- 6
k <- 3
n <- 11

hyper <- dhyper(x, m , n, k)

hyper
## [1] 0.2426471 0.4852941
round(sum(hyper[1:2]),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?

m <- 6 
n <- 19 
k <- 6 
x <- 1 

hyper <- 1 - phyper(x,m,n,k)

round(sum(hyper), 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.

lower <- 1040
upper <- 1460

mean <- 800
sd <- sqrt(90000)

prob  <- pnorm(upper, mean, sd) - pnorm(lower, mean, sd)

round(prob, 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.

mean <- 106
sd <- 4

upper <- 111
lower <- 103

prob <- pnorm(upper, mean, sd) - pnorm(lower, mean, sd)
round(prob, 4)
## [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 <- 3.34
sd <- 0.07
probs <- c(.03, .97)

percentiles <- qnorm(probs, mean, sd)
round(percentiles, 2)
## [1] 3.21 3.47

Therefore, the length of 3.21cm represents the 3rd percentile and the length of 3.47cm represents the 97th percentile. The top 3% of nails are longer than 3.47cm, and the bottom 3% of nails are shorter than 3.21cm.

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 <- 75.8
sd <- 8.1
probs <- .91

A_grade <- qnorm(probs, mean, sd)

round(A_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%.
Approximate the (binomial) probability using the normal distribution.

x <- 96
n <- 155
prob <- .61

binom <- dbinom(x, n, prob)

mean <- n*prob
variance <- n*prob*(1-prob)
sd <- sqrt(variance)

normal_approx <- pnorm(96.5, mean, sd) - pnorm(95.5, mean, sd)

round(binom, 4)
## [1] 0.064
round(normal_approx, 4)
## [1] 0.0638

The results of both the binomial function and the normal approximation are extremely similar which shows that the normal approximation method is valid.