#Objective: HW1 #Author: Zhiwu #Date: Jan 17,2018 #Define function for new variable zhang=function(k,dfx,df1,df2){ x2=rchisq(k,dfx) f=rf(k,df1,df2) y=x2+f return(y) } #Distribution of the variables k=10000 myZhang=zhang(k,dfx=1,df1=1,df2=10) plot(myZhang) hist(myZhang) #Define function for new statistics ZhangStatistics=function(k,size=30,dfx=1,df1=1,df2=10){ rr=replicate(k, { s=zhang(size,dfx,df1,df2) theMax=max(s) theMin=min(s) range=theMax-theMin }) return(rr) } #Distribution of the statistics myStatistics=ZhangStatistics(10000,size=200,dfx=1,df1=1,df2=10) length(myStatistics) plot(myStatistics) hist(myStatistics) plot(density(myStatistics))