#--------------------------# # Loesungen Ueblatt 7 # #--------------------------# # 1b) n = 5 N = 10000 x5 = rep(0,N) x10 = rep(0,N) x15 = rep(0,N) x20 = rep(0,N) y5 = rep(0,N) y10 = rep(0,N) y15 = rep(0,N) y20 = rep(0,N) for(k in 1:N) { phi1n = rnorm(n) phi2n = rnorm(2*n) phi3n = rnorm(3*n) phi4n = rnorm(4*n) x5[k] = sum(phi1n^2)/n x10[k] = sum(phi2n^2)/(2*n) x15[k] = sum(phi3n^2)/(3*n) x20[k] = sum(phi4n^2)/(4*n) y5[k] = prod(phi1n^2) y10[k] = prod(phi2n^2) y15[k] = prod(phi3n^2) y20[k] = prod(phi4n^2) } summary(x5) summary(x10) summary(x15) summary(x20) summary(y5) summary(y10) summary(y15) summary(y20) # 1c) par(mfrow=c(2,2)) hist(x5,breaks=50) hist(x10,breaks=50) hist(x15,breaks=50) hist(x20,breaks=50) par(mfrow=c(2,2)) b1 = max(y5)/0.05 b2 = max(y10)/0.05 b3 = max(y15)/0.05 b4 = max(y20)/0.05 hist(y5,breaks=b1,xlim=c(0,2)) hist(y10,breaks=b2,xlim=c(0,2)) hist(y15,breaks=b3,xlim=c(0,2)) hist(y20,breaks=b4,xlim=c(0,2)) # 1d) par(mfrow=c(2,2)) plot(sort(x5)) plot(sort(x10)) plot(sort(x15)) plot(sort(x20)) par(mfrow=c(2,2)) plot(sort(y5)) plot(sort(y10)) plot(sort(y15)) plot(sort(y20)) # 1e) par(mfrow=c(2,2)) plot(cumsum(x5)/(1:N),ylim=c(0,2)) plot(cumsum(x10)/(1:N),ylim=c(0,2)) plot(cumsum(x15)/(1:N),ylim=c(0,2)) plot(cumsum(x20)/(1:N),ylim=c(0,2)) par(mfrow=c(2,2)) plot(cumsum(y5)/(1:N),ylim=c(0,2)) plot(cumsum(y10)/(1:N),ylim=c(0,2)) plot(cumsum(y15)/(1:N),ylim=c(0,2)) plot(cumsum(y20)/(1:N),ylim=c(0,2))