1. Construct a histogram
hist(errors, main="Histogram of Errors per Day",
xlab="Number of Errors", ylab="Frequency", col="skyblue", border="black")

2. Compute the sample mean
mean_errors <- mean(errors)
cat("Sample Mean:", mean_errors, "\n")
## Sample Mean: 30.7
3. Compute the sample variance and standard deviation
var_errors <- var(errors)
std_dev <- sd(errors)
cat("Sample Variance:", var_errors, "\n")
## Sample Variance: 82.85263
cat("Standard Deviation:", std_dev, "\n")
## Standard Deviation: 9.102342
4. Compute the mode
mode_errors <- names(sort(table(errors), decreasing = TRUE))[1]
cat("Mode:", mode_errors, "\n")
## Mode: 22
6. Compute the interquartile range
IQR_errors <- IQR(errors)
cat("Interquartile Range:", IQR_errors, "\n")
## Interquartile Range: 11.5
7.What number of errors would the manager have 11% of the days with
the greatest number of errors? (Percentile)
eleven_percentile <- quantile(errors, probs = 0.89)
cat("Number of errors for 11% of the greatest days:", eleven_percentile, "\n")
## Number of errors for 11% of the greatest days: 43.64
8.What number of errors per day would you need in order to consider
it an extreme value (outlier)? (Z-score greater than 3)
# Calculate z-scores
z_scores <- (errors - mean_errors) / std_dev
# 8. What number of errors per day would you need in order to consider it an extreme value (outlier)? (Z-score greater than 3)
outliers <- errors[which(abs(z_scores) >3)]
cat("Errors considered as outliers:", outliers)
## Errors considered as outliers:
9.According to the Chebyshev rule, what range contains at least 75%
of the values in the population?
chebyshev_range <- c(mean_errors - 2 * std_dev, mean_errors + 2 * std_dev)
cat("Range containing at least 75% of the values (Chebyshev's Rule):", chebyshev_range, "\n")
## Range containing at least 75% of the values (Chebyshev's Rule): 12.49532 48.90468
10.The manager adds one more day of observation to the study (n =
21). By adding this new observation, the sample mean is now 31.1. What
is the value of the new observation?
new_observation <- (mean_errors * 20 + 31.1 * 21 - 614) / 1
cat("Value of the new observation:", new_observation, "\n")
## Value of the new observation: 653.1
11.A student wants to compute the average of his grades, so he sums
all his grades and the result = 425, the student has an average of 85.
How many courses did the student take this semester?
courses <- sum(errors) / 85
cat("Number of courses the student took:", courses, "\n")
## Number of courses the student took: 7.223529
The student took 7 courses this semester.
12.The annual salaries of employees in a large company are
approximately normally distributed with a mean of $50,000 and a standard
deviation of $15,000.
A) What is the probability that an employee earns less than
$60,000?
B) What is the probability that an employee earns more than
$66,000?
C) What is the probability that an employee earns between $45,000
and $55,000?
# Using R functions for normal distribution
prob_less_than_60k <- pnorm(60000, mean = 50000, sd = 15000)
cat("Probability of earning less than $60,000:", prob_less_than_60k, "\n")
## Probability of earning less than $60,000: 0.7475075
prob_more_than_66k <- 1 - pnorm(66000, mean = 50000, sd = 15000)
cat("Probability of earning more than $66,000:", prob_more_than_66k, "\n")
## Probability of earning more than $66,000: 0.1430612
prob_between_45k_55k <- pnorm(55000, mean = 50000, sd = 15000) - pnorm(45000, mean = 50000, sd = 15000)
cat("Probability of earning between $45,000 and $55,000:", prob_between_45k_55k, "\n")
## Probability of earning between $45,000 and $55,000: 0.2611173