### Angewandte Stochastik II ### Blatt 2 ### WS 2013/14 ### Evgeny Spodarev ### Jürgen Kampf # Aufgabe 1 1+1/4+1+1/5+1/6 5/(1+1/4+1+1/5+1/6) # Aufgabe 2 # a) Dichte st <- rexp(200,rate=2) # 1. Versuch hist(st) #Lösung hist(st, freq=F, main="Exp(2)-Verteilung",breaks=18) curve(dexp(x,rate=2),add=T) # b) Empirische Verteilungsfunktion plot(ecdf(st), main="Empirische Verteilungsfunktion") # c) Eigene empirische Verteilungsfunktion # Erste Möglichkeit #mit vertikalen Linien x_stellen=c(st, st) n=length(st) y_stellen=c((0:(n-1))/n,(1:n)/n) #Hinzufügen zu vorhandenem Plot lines(sort(x_stellen), sort(y_stellen), col="red") #Erzeugen eines neuen Plots plot(sort(x_stellen), sort(y_stellen), type="l", xlab="x", ylab="F_hat_n(x)") lines(c(min(st)-1,min(st)), c(0,0)) lines(c(max(st),max(st+1)),c(1,1)) # Ohne vertikale Linien plot(c(min(st),max(st)),c(0,1),col="white", xlab="x", ylab="F_hat_n(x)") st_sort=sort(st) n=length(st) for(i in (1:(n-1))){ lines(c(st_sort[i],st_sort[i+1]), c(i/n,i/n)) } lines(c(min(st)-1,min(st)), c(0,0)) lines(c(max(st),max(st+1)),c(1,1)) # Alternative # siehe Abschnitte 3.2 und 6.3.1 im R-Skript myECDF<-function(x){ Erg=x; for(i in (1:length(x))){ Erg[i]=sum(st<=x[i])/length(st) }; Erg; } curve(myECDF) ### Großer Nachteil: Dies ist erzeugt keine exakte Treppenfunktion #Aufgabe 3 data(precip) help(precip) # a) quantile(precip,probs=0.25) # b) sort(precip)[10] # c) length(precip)*0.25 sort(precip)[18] # Lösung help(quantile) quantile(precip,probs=0.25,type=2) # d) hist(precip) hist(precip, breaks=5*(0:14)) ### Weder unimodal noch symmetrisch. # e) boxplot(precip) ### Unten drei Ausreißer, oben einer.