Difference between revisions of "TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Bura)/Übungen 2019W/5.3"

From VoWi
Jump to navigation Jump to search
 
Line 4: Line 4:
 
:(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: <code>hist(), mean(), sd(), lines(), abline(), arrows(), legend()</code>
 
:(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: <code>hist(), mean(), sd(), lines(), abline(), arrows(), legend()</code>
  
== Lösungsvorschlag von Ikaly==
+
== Lösungsvorschlag von [[Benutzer:Ikaly|Ikaly]] ==
 
a)
 
a)
  
Line 11: Line 11:
  
 
b)
 
b)
<syntaxhighlight lang=r>
+
<syntaxhighlight lang="r">
 
k= 100
 
k= 100
  

Latest revision as of 19:40, 11 November 2019

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)