# Your code here
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.
# Your code here
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)
# Your code here
meanA <- mean(rexp(30, 1/10))
size <- 10000
x <- numeric(size)
for(i in 1:size){
x[i] <- mean(rexp(30, 1/10))
}
meanB <- mean(x >= 12)
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
The exact sampling distribution of W is \(\bar{X} + \bar{Y}\) ~N(36, 15)
Mean is 35.9047789; Standard deviation is: 10.0005578
hist(wDis)
C) The probability that W is less than 40 is: 0.9017837
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}.\)
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.# 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 = -2.9673439 Standard Deviation = 2.8387381
# Your code here
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\)
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.
# Your code here
xEX <- (40 + 60) / 2
xVX <- ((60 - 40) ^2) / 2
yEX <- (45 + 80) / 2
yVX <- ((80 - 45) ^ 2) / 2
EX <- xEX + yEX
VX <- xVX + yEX
size <- 1000
X <- runif(size, 40, 60)
Y <- runif(size, 45, 80)
W <- X + Y
wEX <- mean(W)
wVX <- var(W)
B)EX is 112.2695294, the VX is 140.3661209 \(P(X + Y < 90) =?\)
# part c
# P(W < 90)
mean <- mean(W < 90)
\(P(X + Y < 90) =0.026\) C) Probability is less than 0.05, it is unlikely