Suppose that the time (in hours) required to repair a car is an exponentially distributed random variable with parameter λ = 1/2. What is the probabil- ity that the repair time exceeds 4 hours? If it exceeds 4 hours what is the probability that it exceeds 8 hours?
# Given parameter for the exponential distribution
lambda <- 1/2
# Probability that repair time exceeds 4 hours
probability_exceeds_4 <- 1 - pexp(4, rate = lambda)
# Probability that repair time exceeds 8 hours given that it exceeds 4 hours
probability_exceeds_8_given_4 <- 1 - pexp(8, rate = lambda) / probability_exceeds_4
# Display the results
cat("Probability that repair time exceeds 4 hours:", probability_exceeds_4, "\n")
## Probability that repair time exceeds 4 hours: 0.1353353
cat("Probability that repair time exceeds 8 hours given that it exceeds 4 hours:", probability_exceeds_8_given_4, "\n")
## Probability that repair time exceeds 8 hours given that it exceeds 4 hours: -6.253721
Suppose that the number of years a car will run is exponentially distributed with parameter μ = 1/4. If Prosser buys a used car today, what is the probability that it will still run after 4 years?
# Given parameter for the exponential distribution
mu <- 1/4
# Probability that the car will still run after 4 years
probability_still_running_after_4_years <- 1 - pexp(4, rate = mu)
# Display the result
cat("Probability that the car will still run after 4 years:", probability_still_running_after_4_years, "\n")
## Probability that the car will still run after 4 years: 0.3678794