########## # Blatt2 # ########## #aufgabe 2 data(michelson) attach(michelson) #a boxplot(Speed ~ Expt) #b exp_1<-Speed[Expt ==1] summary(exp_1) IQR(exp_1) max(exp_1) - min(exp_1) sd(exp_1) sqrt(1/(length(exp_1)-1) * sum((exp_1 - mean(exp_1))^2)) #c dotplot(exp_1) #library(lattice) hist(exp_1, col = c(rep("grey",8),"magenta"), breaks = 8) boxplot(exp_1) points(min(exp_1), col = "magenta", pch =20) #Ausreisser nicht klar definierbar: #faerben in dotplot plot(exp_1, rep(0, 20), pch = 19) points(c(min(exp_1), max(exp_1)), c(0,0), col = "magenta", pch = 20) #aufgabe 3 #d n<-456 k<-110 #Transformation auf ein Zehntel der Originalwerte, sonst numerische Instabilitaet p<-seq(0.01, 0.99, 0.01) L<- p^k * (1-p)^(n-k) plot(p,L,type = "l") abline(v = k/n) #aufgabe 5 x_1<-rpois(100,2) x_2<-rpois(1000,2) x_3<-rpois(10000,2) (est_1<-mean(x_1)) (est_2<-mean(x_2)) (est_3<-mean(x_3)) (bias_1<-(est_1 - 2)) (bias_2<-(est_2 - 2)) (bias_3<-(est_3 - 2)) (var_1<-est_1 / 100) (var_2<-est_2 / 1000) (var_3<-est_3 / 10000) (mse_1<-bias_1^2 + var_1) (mse_2<-bias_2^2 + var_2) (mse_3<-bias_3^2 + var_3) kons_1<-rep(0,100) for(i in 1:100){ kons_1[i]<-mean(rpois(100,2)) } kons_2<-rep(0,100) for(i in 1:100){ kons_2[i]<-mean(rpois(1000,2)) } kons_3<-rep(0,100) for(i in 1:100){ kons_3[i]<-mean(rpois(10000,2)) } par(mfrow = c(3,1)) hist(kons_1, xlim = c(1.3,2.7)) hist(kons_2, xlim = c(1.3,2.7)) hist(kons_3, xlim = c(1.3,2.7))