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? Round your answer to four decimal places. Use the round() function in R.
#assign parameters
n <- 20 # sample size of selected buyers
x <- 9:12 # buyers who prefer red
p_red <- 0.50 # probability of observing red
# determine probability
binom<-dbinom(0:n, n, p_red)
# Round the result to four decimal places
round(sum(binom[9:12]),4)
## [1] 0.6167
# create barplot
barplot(binom, xlab="Buyers", ylab="Probability Buyer Prefers Red")
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.
# parameters
n <- 13 # selcted bulbs sample size
p_defect <- 0.20 # probability of observing defective bulb
x <- 4:5 # probability that less than 6 but more than 3 bulbs from the sample are defective
# calculate the probability
probabilities <- dbinom(x, size = n, prob = 0.20)
# sum of probabilities
p_total <- sum(probabilities)
# Round four decimal places
p_rounded <- round(p_total,4)
p_rounded
## [1] 0.2226
# create barlpot
barplot(
dbinom(
0:n, size = n, prob = p_defect
),
xlab="Success", ylab="Probability")
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.
# parameters
lambda <- 4.2 # mean
s_orders <- 3 # number of special orders
# compute prob
prob <- ppois(s_orders, lambda, lower.tail = TRUE)
# sum of prob & print result
sum_prob <- sum(prob)
round(sum_prob, 4)
## [1] 0.3954
# Barplot
barplot(prob <- ppois(0:3, lambda), xlab="Special Orders", ylab="Probability")
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.
# Parameters
N <- 17 # Total number of bottles of drug shipment
K <- 6 # number of contaminated bottles
n <- 3 # bottles tested sample size
# x value of less than 2 tested bottles are contaminated
x <- 0:1
# Compute prob
prob <- dhyper(x, m = K, n = N - K, k = n)
# Sum the prob where x is less than 2 & print results
sum_prob <- round(sum(prob), 4)
sum_prob
## [1] 0.7279
# plot results
barplot(
probabilities <- dhyper(0:n, m = K, n = N - K, k = n),
xlab="Bottles",
ylab="Probability")
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.
# Parameters
N <- 25 # Total number of employees
K <- 6 # number of employees over 50
n <- 6 # number of employees dismissed
# determine x value of employees dismissed over 50
x <- 2:6
# Compute prob
prob <- dhyper(x, m = K, n = N - K, k = n)
# Sum the prob where x > 1 & round & print results
sum_prob <- sum(prob)
prob_rounded <- round(sum_prob, 4)
prob_rounded
## [1] 0.4529
# plot results
barplot(
probabilities <- dhyper(x, m = K, n = N - K, k = n),
xlab="Dissmissed over 50",
ylab="Probability")
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.
# Parameters
mean_weight <- 800
variance <- 90000
std_deviation <- sqrt(variance)
lower_bound <- 1040
upper_bound <- 1460
# compute Z-scores
z_lower <- (lower_bound - mean_weight) / std_deviation
z_upper <- (upper_bound - mean_weight) / std_deviation
# Calculate the probability
probability <- pnorm(z_upper) - pnorm(z_lower)
round(probability, 4)
## [1] 0.198
# plot results
plot(seq(400, 1200, by = 10), dnorm(seq(400, 1200, by = 10), mean_weight, std_deviation),
type = "l", xlab = "Weight (lbs)", ylab = "Prob Density",
main = "Steer Weights Normal Distribution")
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.
# determine parameters
mu <- 106
std <- 4
l_bound <- 103
u_bound <- 111
# determine z-scores
lower_z <- (l_bound - mu) / std
upper_z <- (u_bound - mu) / std
# compute prob & round & print results
prob <- pnorm(upper_z) - pnorm(lower_z)
round(prob, 4)
## [1] 0.6677
#Plot the Normal Distribution
# Set the mean and standard deviation
mu <- 106
sigma <- 4
# Generate a range of values around the mean
?seq
x <- seq(from = mu - 3*sigma,
to = mu + 3*sigma,
length.out = 1000
)
# Calculate the probability density function
pdf <- dnorm(x = x,
mean = mu,
sd = sigma
)
# Plot the normal distribution
plot(x = x,
y = pdf,
type = 'l',
col = 'red',
lwd = 2,
xlab = 'Diameter',
ylab = 'Density',
main = 'Normal Distribution (Mean Diameter 106 & STD 4)')
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.
# Parameters
mean_length <- 3.34
std_deviation <- 0.07
# Find the z-scores for the 3rd and 97th percentiles
z_03 <- qnorm(0.03)
z_97 <- qnorm(0.97)
# Calculate the lengths corresponding to the percentiles
length_bottom_3_percent <- z_03 * std_deviation + mean_length
length_top_3_percent <- z_97 * std_deviation + mean_length
# Print the results
cat("Length for the bottom 3%:", round(length_bottom_3_percent, 2), "\n")
## Length for the bottom 3%: 3.21
cat("Length for the top 3%:", round(length_top_3_percent, 2))
## Length for the top 3%: 3.47
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.
# Given parameters
mean_score <- 75.8
std_deviation <- 8.1
percentile <- 0.91 # The top 9%
# Find the Z-score for the top 9%
z_score <- qnorm(percentile)
# Calculate the minimum score required for an A grade
minimum_score <- z_score * std_deviation + mean_score
# Round to the nearest whole number
minimum_score_rounded <- round(minimum_score)
cat("The minimum score required for an A grade is approximately", minimum_score_rounded, "rounded to the nearest whole number.\n")
## The minimum score required for an A grade is approximately 87 rounded to the nearest whole number.
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%.
# Parameters
n <- 155 # Total number of computers
p <- 0.61 # Probability that a computer will not crash
k <- 96 # Number of computers that will not crash
# Calculate the binomial coefficient
binomial_coefficient <- choose(n, k)
# Calculate the probability
probability <- binomial_coefficient * p^k * (1 - p)^(n - k)
# rounded
(round(probability, 4))
## [1] 0.064