6.10:

There’s approximately a 79.52% chance that if you toss a fair coin 100,000 times, the number of heads recorded will be between 49,800 and 50,200.

#Probability of getting between 49,800 and 50,200 heads
probability <- pbinom(50200, size = 100000, prob = 0.5) - pbinom(49799, size = 100000, prob = 0.5)

probability
## [1] 0.7952285

6.12:

The probability of rolling one die four times and getting at least one six (0.5177469) is slightly higher than the probability of rolling two dice twenty-four times and getting at least one double sixes (0.4914039). Hence, it is slightly more likely to roll one die four times and get at least one six.

#Probability of getting at least one double six in 24 rolls of two dice
prob_double_six <- 1 - pbinom(0, size = 24, prob = 1/36)

prob_double_six 
## [1] 0.4914039
#Probability of getting at least one six in 4 rolls of one die

prob_single_six<- 1 - pbinom(0, size = 4, prob = 1/6)

prob_single_six
## [1] 0.5177469

6.19:

Approximately 18.45475% of the population has finger lengths within the range of 3.5 to 4 inches, which is the range for which the glove is designed to fit.

#parameters
mu <- 3.20  #Mean
sigma <- 0.35  #SD

#Calculate the percentage of the population the glove will fit
p <- pnorm(4, mean=mu, sd=sigma) - pnorm(3.5, mean=mu, sd=sigma)

#Convert percentage to percentage points
percentage <- p * 100

percentage
## [1] 18.45475

6.22:

The output shows that almost all of the data falls within 1 standard deviation from the mean, with about 99.70% of the data in that range. Within 2 and 3 standard deviations, we capture all the data, meaning 100% falls within those intervals. Comparing these findings to the typical expectations for normal distributions (68%, 95%, and 99.7%), it seems our data slightly surpasses those expectations, indicating a pretty normal distribution overall.

#Load the father.son dataset
library(UsingR)
data(father.son)
#fheight variable
fheight <- father.son$fheight

#mean and standard deviation of fheight
mu <- mean(fheight)
sigma <- sd(fheight)
#the intervals
intervals <- c(1, 2, 3)

#z-score for each interval
z_scores <- intervals * sigma
#cumulative probabilities for each interval
cumulative_probs <- pnorm(z_scores)
#the percentage of data within each interval
percent_within_interval <- cumulative_probs * 100

#the results
cat("Percentage of data within 1, 2, and 3 standard deviations from the mean:\n")
## Percentage of data within 1, 2, and 3 standard deviations from the mean:
print(percent_within_interval)
## [1]  99.69732 100.00000 100.00000
# Comparison with 68%, 95%, and 99.7%
comparison_percentages <- c(68, 95, 99.7)
cat("\nComparison with percentages 68%, 95%, and 99.7%:\n")
## 
## Comparison with percentages 68%, 95%, and 99.7%:
print(comparison_percentages)
## [1] 68.0 95.0 99.7

6.24:

#Uniform(0, 1) distribution
uniform_mean <- 0.5
uniform_sd <- sqrt(1/12)

uniform_sd_1 <- pnorm(uniform_mean + uniform_sd) - pnorm(uniform_mean - uniform_sd)
uniform_sd_2 <- pnorm(uniform_mean + 2 * uniform_sd) - pnorm(uniform_mean - 2 * uniform_sd)
uniform_sd_3 <- pnorm(uniform_mean + 3 * uniform_sd) - pnorm(uniform_mean - 3 * uniform_sd)

#Exponential(1/5) distribution
exp_mean <- 5
exp_sd <- 5

exp_sd_1 <- pexp(exp_mean + exp_sd, rate = 1/5) - pexp(exp_mean - exp_sd, rate = 1/5)
exp_sd_2 <- pexp(exp_mean + 2 * exp_sd, rate = 1/5) - pexp(exp_mean - 2 * exp_sd, rate = 1/5)
exp_sd_3 <- pexp(exp_mean + 3 * exp_sd, rate = 1/5) - pexp(exp_mean - 3 * exp_sd, rate = 1/5)

#the results
uniform_results <- c(uniform_sd_1, uniform_sd_2, uniform_sd_3)
exp_results <- c(exp_sd_1, exp_sd_2, exp_sd_3)

cat("Uniform results:\n")
## Uniform results:
uniform_results
## [1] 0.2011659 0.3901656 0.5568614
cat("Exponential results:\n")
## Exponential results:
exp_results
## [1] 0.8646647 0.9502129 0.9816844

6.25:

The q-q plot comparison among the Uniform(0,1), Normal(0,1), and t-distribution (df=3) highlights their unique characteristics. The Uniform(0,1) plot shows nearly perfect linearity, indicating a distribution resembling normality with short tails. In contrast, the Normal(0,1) plot presents a straight line, affirming its adherence to normality. However, the t-distribution plot exhibits slight curvature, especially in the tails, indicating deviations from normality and the presence of longer tails typical of distributions with lower degrees of freedom. Overall, the q-q plot effectively illustrates the departure from normality in each distribution, offering insights into their tail lengths and conformity to the normal distribution.

#generating random samples from each distribution
sample_uni <- runif(100, min = 0, max = 1)
sample_normal <- rnorm(100, mean = 0, sd = 1)
sample_t <- rt(100, df = 3)

#q-q plots for each distribution
par(mfrow = c(1, 3))  #Arrange plots in a single row
qqnorm(sample_uni, main = "Uniform(0,1)")
qqline(sample_uni, col = "red")  #line to indicate normality
qqnorm(sample_normal, main = "Normal(0,1)")
qqline(sample_normal, col = "red") 
qqnorm(sample_t, main = "t-distribution (df=3)")
qqline(sample_t, col = "red")

6.29:

There is approximately a 0.376% chance that the player achieves a batting average greater than 0.350 in a 600-at-bat season.

#Parameters
mu <- 180  #Mean
sigma <- sqrt(126)  #Sd
#Batting average threshold
x <- 0.350
#z-score
z <- (x * 600 - mu) / sigma
#probability using normal approximation
probability <- 1 - pnorm(z)
probability
## [1] 0.003763158

6.30:

The output indicates that there is approximately a 0.087% chance of observing 550 or more individuals in favor of the issue in a sample of 1,000 individuals from a population evenly divided on the issue.

#Parameters
n <- 1000  # Sample size
p <- 0.5   #Probability of success (evenly divided population)
#Mean and sd of the binomial distribution
mu <- n * p
sigma <- sqrt(n * p * (1 - p))
#Probability of having 550 or more
probability <- pnorm(550 - 0.5, mu, sigma, lower.tail = FALSE)
probability
## [1] 0.000872085

6.31:

The output of is essentially 0 when rounded, meaning that it would be highly unusual for the elevator to exceed the safe weight limit under these conditions.

#Parameters
mu <- 180   #Mean weight of adults
sigma <- 25 #SD of adult weights
n <- 15     #Number of passengers in the elevator
W_limit <- 3500 #Safe weight limit of the elevator
#mean and standard deviation of total weight
mu_total <- n * mu
sigma_total <- sqrt(n) * sigma
#z-score
z <- (W_limit - mu_total) / sigma_total
#probability calculation
probability <- 1 - pnorm(z)
probability
## [1] 1.110223e-16

7.2:

The mean of the sample means (approximately 592.5095) closely aligns with the sample mean of the original rivers data set (approximately 591.1844), indicating good agreement between the two measures. This suggests that the average of the sample means, derived from 1,000 random samples of size 10 from the rivers data set, accurately reflects the central tendency observed in the original data set.

#rivers dataset
library(UsingR)
data(rivers)
#Set seed for reproducibility
set.seed(123)
num_samples <- 1000 #Number of random samples
sample_size <- 10 #Sample size

# Take 1,000 random samples of size 10 from the rivers data set
random_samples <- replicate(num_samples, sample(rivers, sample_size))

#mean of each sample
sample_means <- apply(random_samples, 2, mean)

#mean of the sample means
mean_of_sample_means <- mean(sample_means)

#sample mean of the original rivers dataset
sample_mean_rivers <- mean(rivers)

#Print the results
cat("Mean of the sample means:", mean_of_sample_means, "\n")
## Mean of the sample means: 592.5095
cat("Sample mean of the original rivers dataset:", sample_mean_rivers, "\n")
## Sample mean of the original rivers dataset: 591.1844