pop <- c(3,6,7,9,11,14)
min(pop)
[1] 3
minimum <- apply(combn(pop, 3), 2, min)
minimum
[1] 3 3 3 3 3 3 3 3 3 3 6 6 6 6 6 6 7 7 7 9
mean(minimum) #mean of sampling dist
[1] 4.8
ggplot(data=data.frame(minimum), aes(x = data.frame(minimum))) +
geom_density() +
theme_bw()
The mean of the sampling distribution is
mean(minimum) = 4.8
The value of the parameter is min(pop) = 3
funct <- function(x){3*x^2/8}
integrate(funct, 0, 2)$value #should be a 1
[1] 1
integrate(funct, 0, 1/5)$value
[1] 0.001
curve(funct)
abline(v=0)
abline(v=1/5)
abline(h=0)
integrate(funct, 0, 1/5)$value
[1] 0.001
\(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)
n <- 10^4 - 1
result <- numeric(n)
for(i in 1:n){
result[i] <- mean(rexp(30, 1/10))
}
mean(result)
[1] 9.970705
mean(result >= 12)
[1] 0.1340134
library(ggplot2)
ggplot(data = data.frame(x = result), aes(x = x)) +
geom_density() +
stat_function(fun = dgamma, args = list(30*1, 30/10), color = "blue") +
theme_bw()
The expected value of the sample mean is \(1/\lambda\), which is \(1/(1/10)\). The sample mean is
9.971 and the proportion of sample means that are greater than or equal to 12 is 0.134. Because 0.134 is greater than 0.05, we have no evidence to suggest that a mean of 12 is unusual for a sample of size 30 from \(\text{Exp}(\lambda = 1/10)\).
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.# part b
n <- 10^4 - 1
x <- numeric(n)
y <- numeric(n)
for(i in 1:n){
x[i] <- mean(rnorm(10, 20, 8))
y[i] <- mean(rnorm(15, 16, 7))
}
W <- x + y
hist(W)
mean(W)
[1] 35.96297
sd(W)
[1] 3.094161
foo <- sqrt(8^2/10 + 7^2/15)
# part c.
mean(W < 40)
[1] 0.9033903
#exact:
pnorm(40, 36, foo)
[1] 0.9008718
P(W<40) = 0.9008718
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.
n <- 10000
x <- numeric(n)
y <- numeric(n)
for(i in 1:n){
x[i] <- mean(rnorm(9, 7, 3))
y[i] <- mean(rnorm(12, 10, 5))
}
result <- x - y
ggplot(data = data.frame(x = result), aes(x = x)) +
geom_density() +
geom_vline(xintercept = mean(result), color="red") +
geom_vline(xintercept=-3, color="blue") +
geom_vline(xintercept=sd(result), color="yellow") +
geom_vline(xintercept=1.76, color="green") +
theme_bw()
mean(result)
[1] -2.989098
sd(result)
[1] 1.785281
# part c.
# simulated answer
mean(result < -1.5)
[1] 0.7967
# Exact answer
pnorm(-1.5, -3, sqrt(3^2/9 + 5^2/12))
[1] 0.8035146
# Your code here
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
\(P(X + Y < 90) =?\)
# part c
# P(W < 90)