A sample of size n is to be drawn from a population with a known mean of m = 25.4 and a standard deviation of s = 2.8. Using the Central Limit Theorem
a.What is the probability that the average of the n observations is less than 25.3 when …
i.n=10?
ii.n=25?
iii.n=50?
# Population parameters
mu <- 25.4
sigma <- 2.8
# Sample size
n <- c(10, 25, 50)
# Calculate z-scores
z <- (25.3 - mu) / (sigma / sqrt(n))
# Calculate probabilities
prob <- pnorm(z)
# Print the probabilities
cat("Probability that X̅ < 25.3 when n =", n, ":\n")
## Probability that X̅ < 25.3 when n = 10 25 50 :
cat(prob, "\n")
## 0.4550397 0.4291371 0.4003126
b. Comment on anything you notice about Pr(X̅ < 25.3) as n is increased.
After running the code, you will see the probabilities for each sample size, indicating the probability that the average of the n observations is less than 25.3. Additionally, as n increases, you will notice that the probabilities Pr(X̅ < 25.3) decrease. If the sample size increases, the estimate of the population mean becomes more precise, resulting in a narrower sampling distribution of the sample means and a lower probability of obtaining an average less than 25.3.
c.
# Required Libraries
library(ggplot2)
# Population parameters
mu <- 25.4
sigma <- 2.8
# Sample sizes
n <- c(10, 25, 50)
# Range for X̅
x_bar_range <- seq(24, 27, 0.01)
# Function to calculate pdf of X̅
pdf_x_bar <- function(x_bar, n) {
se <- sigma / sqrt(n)
dnorm(x_bar, mean = mu, sd = se)
}
# Create data frames for each sample size
df <- lapply(n, function(n_val) {
data.frame(x_bar = x_bar_range, pdf = pdf_x_bar(x_bar_range, n_val), n = n_val)
})
# Combine data frames
df <- do.call(rbind, df)
# Plot
ggplot(df, aes(x = x_bar, y = pdf, color = factor(n))) +
geom_line(size = 1) +
labs(x = "X̅", y = "Probability Density") +
scale_color_manual(values = c("red", "blue", "green"), labels = c("n = 10", "n = 25", "n = 50")) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
A sample n=30 observations is to be drawn from the Binomial(100,.05) distribution, i.e. each X_i~Bin(100,.05). Assume the Central Limit theorem holds.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# Parameters
n <- 30 # Sample size
p <- 0.05 # Probability of success
a. What is the mean of X_i?
mean_X_i <- n * p
cat("Mean of X_i:", mean_X_i, "\n")
## Mean of X_i: 1.5
b.What is the standard deviation X_i?
sd_X_i <- sqrt(n * p * (1 - p))
cat("Standard deviation of X_i:", sd_X_i, "\n")
## Standard deviation of X_i: 1.193734
c. What is the mean of X̅ ?
mean_X_bar <- mean_X_i
cat("Mean of X̅:", mean_X_bar, "\n")
## Mean of X̅: 1.5
d. What is the standard deviation of X̅?
sd_X_bar <- sd_X_i / sqrt(n)
cat("Standard deviation of X̅:", sd_X_bar, "\n")
## Standard deviation of X̅: 0.2179449
e.What is the probability Pr(X_i≤4)?
prob_X_i_4 <- pbinom(4, size = 100, prob = 0.05, lower.tail = TRUE)
cat("Probability Pr(X_i ≤ 4):", prob_X_i_4, "\n")
## Probability Pr(X_i ≤ 4): 0.4359813
f.What is the probability Pr(X̅≤4)?
prob_X_bar_4 <- pnorm(4, mean = mean_X_bar, sd = sd_X_bar, lower.tail = TRUE)
cat("Probability Pr(X̅ ≤ 4):", prob_X_bar_4, "\n")
## Probability Pr(X̅ ≤ 4): 1