TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Bura)/Übungen 2019W/5.3

From VoWi
< TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Bura)‎ | Übungen 2019W
Revision as of 18:40, 11 November 2019 by Ikaly (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Histogram

Set k <- 100 and generate x <- rnorm(sample(k:(2*k),1), runif(1,0,k), rexp(1,1/k))

(a) Explain what is realized in x.
(b) Plot a histogram of x. Mark its mean in red, its standard deviation in blue and add a legend which explains them both. Helpful commands: hist(), mean(), sd(), lines(), abline(), arrows(), legend()

Lösungsvorschlag von Ikaly[edit]

a)

Es werden Werte aus der Normalverteilung mittles Uniformverteilten (1,0,k) mean und exponentialverteilten (1,1/k) als Standard deviation erstellt.


b)

k= 100

x = rnorm(sample(k:(2*k),1), runif(1,0,k), rexp(1,1/k))
mean = mean(x)
sd = sd(x)

hist(x, main="Normalverteilung")
abline(v=c(mean-sd,mean,mean+sd), col=c("blue", "red", "blue"), lty=c(2,1,2), lwd=c(3,1, 3))
legend("topleft", legend=c("Mean", "Standard Deviation"),
       col=c("red", "blue"), lty=1:2, cex=0.8)