#3

Let X be the random variable of Exercise 2. (a) Calculate the function f(x) = P(|X −10| ≥ x). (b) Nowgraphthe function f(x), and on the sameaxes, graphthe 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).

# Define the pmf of X
pmf_X <- function(k) {
  return(1 / (k * (k + 1)))
}

# Calculate f(x) for given x
f_x <- function(x) {
  sum_pmf_leq <- sum(pmf_X(1:(10 - x)))
  sum_pmf_geq <- sum(pmf_X((10 + x):100))  # Assuming large upper bound
  return(sum_pmf_leq + sum_pmf_geq)
}

# Define g(x)
g_x <- function(x) {
  return(100 / (3 * x^2))
}

# Generate x values for plotting
x_values <- seq(0.1, 10, by = 0.1)

# Calculate f(x) and g(x) for each x
f_values <- sapply(x_values, f_x)
g_values <- sapply(x_values, g_x)

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