### Angewandte Stochastik II ### Blatt 3 ### Evgeny Spodarev ### Jürgen Kampf # Aufgabe 1 widerstand <- read.table("widerstand.txt", col.names = c("radius", "R")) # a) plot(widerstand) plot(widerstand$radius, widerstand$R, xlab="Radius", ylab="Widerstand") plot(R~radius, data=widerstand) plot(widerstand[,1], widerstand[,2], xlab="Radius", ylab="Widerstand") # Die Größen sind negativ korreliert. Je größer der Radius, desto kleiner der # Widerstand. # b) attach(widerstand) cov(radius,R) # -0.6428587 # c) cor(radius, R, method="pearson") # -0.5592919 cor(radius, R, method="spearman") # -0.9761905 # d) rad_Rank <- 0 R_Rank <- 0 n <- length(radius) for(i in 1:n) { rad_Rank[i] = sum(radius < radius[i])+1 R_Rank[i] = sum(R < R[i])+1 } numerator <- sum((rad_Rank-mean(rad_Rank)) * (R_Rank - mean(R_Rank))) denominator <- sqrt(sum((rad_Rank-mean(rad_Rank))^2) * sum((R_Rank-mean(R_Rank))^2)) numerator / denominator # -0.9761905 # Stimmt mit der Antwort aus Teil c) überein. # e) x=c(10,9,0) y=c(0,10,1) cor(x, y, method="pearson") # 0.3351648 cor(x, y, method="spearman") # -0.5 plot(x,y) ### Aufgabe 2 t <- read.table("temperatur.txt", col.names="temp") par(mfrow=c(2,2)) # b) quant <- 1/61*1:60 # k/(n+1) # Exponentialverteilung plot(-1/.05 * log(1-quant), sort(t$temp), main = "QQ-Plot, Exponentialverteilug", xlab = "Quantile der Exponentialverteilung", ylab = "empirische Quantile") abline(0,1) # Gleichverteilung plot(20+2*quant, sort(t$temp), main = "QQ-Plot, Gleichverteilug", xlab = "Quantile der Gleichverteilug", ylab = "empirische Quantile") abline(0,1) # Normalverteilung plot(qnorm(quant, 21, 1), sort(t$temp), main = "QQ-Plot, Normalverteilung", xlab = "Quantile der Normalverteilung", ylab = "empirische Quantile") abline(0,1) # Weibull-Verteilung plot((-21 * log(1-quant)), sort(t$temp), main = "QQ-Plot, Weibull-Verteilug", xlab = "Quantile der Weibull-Verteilug", ylab = "empirische Quantile") abline(0,1) # d) qqnorm(t$temp) qqline(t$temp)