####################### # ---- Aufgabe R ---- # ####################### # a) a = 1:5 b = -2:2 sum(a * b) a %*% b # b) log(mean(a)) mean(log(a)) # c) cumprod(1:10) exp(cumsum(log(1:10))) ####################### # ---- Aufgabe 4 ---- # ####################### w = sample(1:6,size = 3000, replace = TRUE) s = w == 6 # erwartete Anzahl Sechser beim k-ten Wurf: erw = 1:3000 * 1/6 # erwartete relatibe Haeufigkeit: 1/6 erw2 = 1/6 # tats. Anz. Sechser: tat = cumsum(s) D = tat-erw R = tat/c(1:3000) - erw2 # plotten: par(mfcol=c(2,1)) plot(x=1:3000, y = D, col = 1, lwd = 2, type="l") abline(h = 0, lwd = 2, lty = "dashed", col = 3) plot(x=1:3000, y = R, col = 2, lwd = 2, type="l") abline(h = 0, lwd = 2, lty = "dashed", col = 3)