X ~ Unif(3, 14)
X ~ Unif(3, 14)
pop <- c(3, 6, 7, 9, 11, 14)
my.min <- numeric(1000)
for(i in 1:1000){
y <- runif(3, 3, 14)
my.min[i] <- min(y)
}
hist(my.min)
Answer: The mean of the sampling distribution is 3.0022201. The value of the parameter is 3.
f <- function(x){3 * x ^ 2/ 8}
value <- integrate(f, 0, 1/5)$value
\(P(0 \leq Y \leq 1/5) =\) 0.001.
A friend claim that she has drawn a random sample of size 30, from the exponential distribution with \(\lambda = 1/10\). The mean of her sample is 12.
library(tidyverse)
set.seed(123)
#Question A
meanA <- mean(rexp(30, 1/10))
#Question B
size <- 10000
x <- numeric(size)
for(i in 1:size){
x[i] <- mean(rexp(30, 1/10))
}
meanB <- mean(x >= 12)
A: The expected value of the sample mean is 9.1123961.
B: The proportion of the sample means that are as large or larger than 12 is 0.1342.
C: Because the proportion is greater than 0.05, the mean of 12 is not unusual.
Let \(X_1, X_2, \ldots , X_{10} \overset{i.i.d}\sim N(20, 8)\) and \(Y_1, Y_2, \ldots, Y_{15} \overset{i.i.d}\sim N(16, 7)\). Let \(W = \bar{X} + \bar{Y}.\)
R and plot your results. Check that the simulated mean and standard error are close to the theoretical mean and standard error.size <- 1000
xDis <- numeric(size)
yDis <- numeric(size)
for(i in 1:size){
xDis[i] <- mean(rnorm(10, 20, 8))
yDis[i] <- mean(rnorm(15, 16, 7))
}
wDis <- xDis + yDis
A: The exact sampling distribution of W is \(\bar{X} + \bar{Y}\) ~ N(36, 15).
Graph for B
hist(wDis)
B: Mean is 35.9047789. Standard deviation is: 10.0005578.
C: The probability that W is less than 40 is : 0.9023376.
5. Let \(X_1, X_2, \ldots , X_{9} \overset{i.i.d}\sim N(7, 3)\) and \(Y_1, Y_2, \ldots, Y_{12} \overset{i.i.d}\sim N(10, 5)\). Let \(W = \bar{X} - \bar{Y}.\)
a. Give the exact sampling distribution of $W$.
b. Simulate the sampling distribution of $W$ in `R` and plot your results using `ggplot2`. Check that the simulated mean and the standard error are close to the theoretical mean and the standard error.
c. Use your simulation to find $P(W < -1.5)$. Calculate an exact answer and compare.
A: The exact sampling distribution of W is \(\bar{X} - \bar{Y}\) ~ N(-3, -2).
# part b.
library(ggplot2)
size <- 1000
xDis <- numeric(1000)
yDis <- numeric(1000)
for(i in 1:size){
xDis[i] <- mean(rnorm(9, 7, 3))
yDis[i] <- mean(rnorm(12, 10, 5))
}
wDis <- xDis - yDis
# part c.
# simulated answer
simMean <- mean(wDis < -1.5)
# Exact answer
exMean <- pnorm(-1.5, mean(wDis), sd(wDis))
B: Mean is -2.9673439. Standard deviation is 2.8387381.
C: The simulated percentage is: 0.804. The exact percentage is: 0.8080961.
size <- 1000
w2 <- numeric(size)
w4 <- numeric(size)
w5 <- numeric(size)
for(i in 1:size){
w2[i] <- sum(rnorm(2) ^ 2)
w4[i] <- sum(rnorm(4) ^ 2)
w5[i] <- sum(rnorm(5) ^ 2)
}
W2: The mean is 2.1408701. The variance is 4.8589464.
W4: The mean is 4.0637784. The variance is 9.2395798.
W5: The mean is 4.9899208. The variance is 9.8786346.
The mean is typically \(n\). The variance is typically \(2n\).
7. Let \(X\) be a uniform random variable on the interval \([40, 60]\) and \(Y\) a uniform random variable on \([45, 80].\) Assume that \(X\) and \(Y\) are independent.
a. Compute the expected value and variance of $X + Y.$
b. Simulate the sampling distribution of $X + Y.$ Desribe the graph of the distribution of $X + Y$. Compute the mean and variance of the sampling distribution and compare this to the theoretical mean and variance.
c. Suppose the time (in minutes) Jack takes to complete his statistics homework is $\text{Unif}[40, 60]$ and the time JIll takes is $\text{Unif}[40, 60].$ Assume they work independently. One day they announce that their total time to finish an assignment was less than 90 min. How likely is this?
# Part A
xEX <- (40 + 60) / 2
xVX <- ((60 - 40) ^2) / 2
yEX <- (45 + 80) / 2
yVX <- ((80 - 45) ^ 2) / 2
EX <- xEX + yEX
VX <- xVX + yEX
A: The EX of \(X + Y\) is 112.5. The VX of \(X + Y\) is 262.5.
# Part B
size <- 1000
X <- runif(size, 40, 60)
Y <- runif(size, 45, 80)
W <- X + Y
wEX <- mean(W)
wVX <- var(W)
B: The EX of W is 112.2695294. The VX of W is 140.3661209.
\(P(X + Y < 90) =?\)
# part c
# P(W < 90)
mean <- mean(W < 90)
\(P(X + Y < 90) =\) 0.026.
C: Because the probability is less than 0.05, it is unlikely.