Problem 1 a-e:
mean_score <- 78
sd_score <- 6
prop_below_50 <- pnorm(50, mean_score, sd_score)
print(paste("(a) Proportion of class expected to score below 50:", prop_below_50))
## [1] "(a) Proportion of class expected to score below 50: 1.53062673653106e-06"
prop_above_90 <- 1 - pnorm(90, mean_score, sd_score)
print(paste("(b) Proportion of class expected to score above 90:", prop_above_90))
## [1] "(b) Proportion of class expected to score above 90: 0.0227501319481792"
prop_between_60_and_80 <- pnorm(80, mean_score, sd_score) - pnorm(60, mean_score, sd_score)
print(paste("(c) Proportion of class expected to score between 60 and 80:", prop_between_60_and_80))
## [1] "(c) Proportion of class expected to score between 60 and 80: 0.629208761786606"
first_quantile <- qnorm(0.25, mean_score, sd_score)
third_quantile <- qnorm(0.75, mean_score, sd_score)
print(paste("(d) First quantile:", first_quantile))
## [1] "(d) First quantile: 73.9530614988235"
print(paste(" Third quantile:", third_quantile))
## [1] " Third quantile: 82.0469385011765"
fifth_percentile <- qnorm(0.05, mean_score, sd_score)
ninety_fifth_percentile <- qnorm(0.95, mean_score, sd_score)
print(paste("(e) 5th percentile:", fifth_percentile))
## [1] "(e) 5th percentile: 68.1308782382912"
print(paste(" 95th percentile:", ninety_fifth_percentile))
## [1] " 95th percentile: 87.8691217617088"
Problem 2:
n <- 50
mean <- 82
variance <- 51
sd <- sqrt(variance)
x <- rnorm(n, mean, sd)
hist(x, breaks = 10, col = "lightgreen", main = "Histogram of X ~ N(82, 51)", xlab = "X values", ylab = "Frequency")
expected_value <- mean
expected_value
## [1] 82
Explanation/question answering from Question 2: The histogram does seem centralized around the expected value of x (82). This is because the mean is the expected value, and therefore, the most prominently showing value in the set. Because the highest central bar is Representative of the frequency of the values of x in that range (80-85), the mean will be approximately the most often showing value.
Problem 3a (100):
n <- 100
sampleN <- 1000
xBar <- array(NA, sampleN)
for (i in 1:sampleN) {
aSample <- rnorm(n, 0, 1)
xBar[i] <- mean(aSample)
}
hist(xBar, freq = FALSE, col = "lightblue", main = "Histogram of Sample Means (n=100)", xlab = "Sample Mean", ylab = "Density")
x <- seq(min(xBar), max(xBar), by = 0.01)
lines(x, dnorm(x, mean = 0, sd = 1 / sqrt(n)), col = "darkred")
Problem 3a (1000):
n <- 1000
sampleN <- 1000
xBar <- array(NA, sampleN)
for (i in 1:sampleN) {
aSample <- rnorm(n, 0, 1)
xBar[i] <- mean(aSample)
}
hist(xBar, freq = FALSE, col = "lightgreen", main = "Histogram of Sample Means (n=1000)", xlab = "Sample Mean", ylab = "Density")
x <- seq(min(xBar), max(xBar), by = 0.01)
lines(x, dnorm(x, mean = 0, sd = 1 / sqrt(n)), col = "darkblue")
Problem 3b (100):
n <- 100
sampleN <- 1000
xBar <- array(NA, sampleN)
for (i in 1:sampleN) {
aSample <- rnorm(n, 0, 1)
xBar[i] <- mean(aSample)
}
plot(density(xBar), main = "Density Plot of Sample Means (n = 100)", xlab = "Sample Mean", ylab = "Density", col = "blue")
Problem 3b (1000):
n <- 1000
sampleN <- 1000
xBar <- array(NA, sampleN)
for (i in 1:sampleN) {
aSample <- rnorm(n, 0, 1)
xBar[i] <- mean(aSample)
}
plot(density(xBar), main = "Density Plot of Sample Means (n = 1000)", xlab = "Sample Mean", ylab = "Density", col = "green")
Problem 3c (100):
n <- 100
sampleN <- 1000
xBar <- numeric(sampleN)
for (i in 1:sampleN) {
aSample <- rnorm(n, 0, 1)
xBar[i] <- mean(aSample)
}
qqnorm(xBar, main = "Normal QQ Plot for n = 100", xlab = "Theoretical Quantiles", ylab = "Sample Quantiles")
qqline(xBar, col = "red")
Problem 3c (1000):
n <- 1000
sampleN <- 1000
xBar <- numeric(sampleN)
for (i in 1:sampleN) {
aSample <- rnorm(n, 0, 1)
xBar[i] <- mean(aSample)
}
qqnorm(xBar, main = "Normal QQ Plot for n = 1000", xlab = "Theoretical Quantiles", ylab = "Sample Quantiles")
qqline(xBar, col = "red")