3: Let X be the random variable of Exercise 2.

(a) Calculate the function f(x) = P(|X − 10| ≥ x).

mu <- 10 
variance <- 100/3 
sigma <- sqrt(variance) 

f <- function(x) {
  1 - pnorm(mu + x, mean = mu, sd = sigma) + pnorm(mu - x, mean = mu, sd = sigma)
}

x_values <- seq(0, 10, by = 0.1)
f_values <- sapply(x_values, f)

cat("f(1) =", f(1), "\n")
## f(1) = 0.8624902

(b) Now graph the function f(x), and on the same axes, graph the Chebyshev function g(x) = 100/(3x2). Show that f(x) ≤ g(x) for all x > 0, but that g(x) is not a very good approximation for f(x).

g <- function(x) {
  100 / (3 * x^2)
}

g_values <- sapply(x_values, g)

plot(x_values, f_values, type = "l", col = "blue", xlab = "x", ylab = "Probability", 
     main = "Comparison of f(x) and g(x)")
lines(x_values, g_values, type = "l", col = "red")
legend("topright", legend = c("f(x)", "g(x)"), col = c("blue", "red"), lty = 1)