Part C, D, and E using the R Statistical Software. 4. (20 points) Let Xi be a ra
ID: 3260829 • Letter: P
Question
Part C, D, and E using the R Statistical Software.
Explanation / Answer
ANSWER: COPY THE FOLLOWING CODE TO YOUR R SCRIPT AS IT AS OTHERWISE IT WONT WORK.
rm(list=ls(all=TRUE))
S=c(0,1) # Sample Space
N=100 # Number of Observations
X=sample(S,N,replace=TRUE) # Random Variable X
Y=sum(X) # Random Variable Y
Z=Y/100 # Random Variable Z
# ANSWER C
# WE NEED TO GENERATE 25 RANDOM SAMPLES OF Z
Z=rep()
for(i in 1:25)
{
X=sample(S,N,replace=TRUE)
Y=sum(X)
Z[i]=Y/100
}
mean(Z) # SAMPLE MEAN OF Z
var(Z) # SAMPLE VARIANCE OF Z
stem(Z) # STEM AND LEAF PLOT OF Z
boxplot(Z,horizontal=TRUE) # BOX PLOT OF Z
# ANSWER D
# WE NEED TO GENERATE 1000 RANDOM SAMPLES OF Z
Z=rep()
for(i in 1:1000)
{
X=sample(S,N,replace=TRUE)
Y=sum(X)
Z[i]=Y/100
}
mean(Z) # SAMPLE MEAN OF Z
var(Z) # SAMPLE VARIANCE OF Z
# ANSWER E
# WE NEED TO PLOT HISTOGRAMOF Z FROM PART D
library(MASS)
truehist(Z,h=0.03)
## IT CLEARLY SHOWS THAT Z IS COMING FROM NORMAL DISTRIBUTION
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.