Question #1
#Walks currently
Juan_walks <- c(79, 108,41,145,135)
Juan_walks
## [1] 79 108 41 145 135
#AVG walks wanted per season
walks_wanted <- 100
#Number of Seasons
n_seasons <- 6
# Needed Home-runs on season 5
x_6 <- n_seasons*walks_wanted - sum(Juan_walks)
# Minimum number of walks needed by Juan
x_6
## [1] 92
#Juan's performance
Juan_woks <- c(79, 108,41,145,135,92)
mean(Juan_woks)
## [1] 100
#Standard Deviation
sd(Juan_woks)
## [1] 38.20995
#Max # of walks
max(Juan_woks)
## [1] 145
#Min # of walks
min(Juan_woks)
## [1] 41
summary(Juan_woks)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 41.00 82.25 100.00 100.00 128.25 145.00
Question #2
n_1 <- 7
n_2 <- 9
y_1 <- 102000
y_2 <- 91000
#Mean salary overall
salary_avg <- (n_1 * y_1 + n_2 * y_2)/(n_1+n_2)
salary_avg
## [1] 95812.5
Question #3
doubles_hit <- read.table("doubles_hit.csv", header = TRUE, sep = ",")
dub_hits <- doubles_hit$doubles_hit
# Mean
dub_mean <- mean(dub_hits)
dub_mean
## [1] 23.55
# Median
dub_med <- median(dub_hits)
dub_med
## [1] 23.5
# Length
dub_n <- length(dub_hits)
dub_n
## [1] 100
# Standard deviation
dub_sd <- sd(dub_hits)
dub_sd
## [1] 13.37371
# Within 1 standard deviation
dub_1sd <- sum((dub_hits - dub_mean)/dub_sd < 1)/dub_n
dub_1sd
## [1] 0.79
# Difference from empirical
dub_1sd - 0.68
## [1] 0.11
# Within 2 standard deviation
dub_2sd <- sum((dub_hits - dub_mean)/dub_sd < 2)/dub_n
dub_2sd
## [1] 1
# Difference from empirical
dub_2sd - 0.95
## [1] 0.05
# Within 3 standard deviation
dub_3sd <- sum((dub_hits - dub_mean)/dub_sd < 3)/dub_n
dub_3sd
## [1] 1
# Difference from empirical
dub_3sd - 0.9973
## [1] 0.0027
# Create a Histogram
hist(dub_hits,xlab = "Total of Doubles Hit",col ="green",border = "red",xlim = c(0,50), ylim = c(0,25), breaks = 5)