In: Statistics and Probability
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL R commands you used to reach your answers in a word or pdf document. Also, report everything you are asked to do so.
Problem 3 :
In lab lecture notes and demo code, I simulated random samples from Exp(1) to verify classical central limit theorem numerically. I also stressed that no matter what type of random samples you use, the standardized partial sum Sn always converge to N(0, 1). In this problem, simulate random samples from the following distributions:
1. Bernoulli(0.5) with µ = 0.5 and σ^2 = 0.25. (Hint: You can use rbinom to generate Bernoulli random numbers.) 1
2. Uniform(0, 1) with µ = 0.5 and σ^2 = 1/12.
3. Possion(1) with µ = 1 and σ^2 = 1.
For each case, set simulation times N to be 1000 and for each simulation, generate n = 2000 random numbers. Report 3 pieces of code, 3 Q-Q plots and your conclusion. To get all the answers, you only need slightly adjust my demo code
Bernoulli(0.5)
N <- 2000 # Number of trials (population size)
n <- 1000 # Number of simulations
standardized_sample_mean = rep(0,s)
EX <- 0.5 #Expectation
VarX <- 0.25 #Variance
for (i in 1:n){
samp <- rbinom(1, size = N, prob = 0.05) #Sampling the
Distribution
sample_mean <- mean(samp) # sample mean
standardized_sample_mean[i] <- sqrt(N)*(sample_mean -
EX)/sqrt(VarX) #Standarizing the Sample Mean
}
hist(standardized_sample_mean,prob=TRUE)
qqnorm(standardized_sample_mean)
Uniform(0, 1)
N <- 2000 # Number of trials (population size)
n <- 1000 # Number of simulations
standardized_sample_mean = rep(0,s)
EX <- 0.5 #Expectation
VarX <- 0.25 #Variance
for (i in 1:n){
samp <- runif( N, 0, 1) #Sampling the Distribution
sample_mean <- mean(samp) # sample mean
standardized_sample_mean[i] <- sqrt(N)*(sample_mean -
EX)/sqrt(VarX) #Standarizing the Sample Mean
}
hist(standardized_sample_mean,prob=TRUE)
qqnorm(standardized_sample_mean)
Possion(1)
N <- 2000 # Number of trials (population size)
n <- 1000 # Number of simulations
standardized_sample_mean = rep(0,s)
EX <- 1 #Expectation
VarX <- 1 #Variance
for (i in 1:n){
samp <- rpois(N,1) #Sampling the Distribution
sample_mean <- mean(samp) # sample mean
standardized_sample_mean[i] <- sqrt(N)*(sample_mean -
EX)/sqrt(VarX) #Standarizing the Sample Mean
}
hist(standardized_sample_mean,prob=TRUE)
qqnorm(standardized_sample_mean)