---
title: "Statistik Notebook 31.5.2017"
author: "ste"
date: "31. Mai 2017"
output:
  html_document: default
  word_document: default
---


# Statistik SS 2017: R Notebook zur Vorlesung

### Normalverteilung

```{r}
pnorm(q=2)
qnorm(p = 0.90)
curve(pnorm, from=-4,to=4, lwd=2, col="red")
grid()
table(rnorm(n=1e6) < 2)
```

### Umfragedaten: Groesse der Mütter

```{r}
Umfrage = read.csv2("https://goo.gl/WNgGMJ")
Groesse = na.omit(Umfrage$GroesseM)
Groesse.Dichte = density(Groesse)
mu = mean(Groesse)
mu
sigma = sd(Groesse)
sigma
plot(Groesse.Dichte, lwd=2, col="lightblue", main="Dichte")
x = seq(from=min(Groesse), to=max(Groesse), length.out = 100)
lines(x, dnorm(x, mean = mu, sd = sigma), lwd=2, col="red", type="l")
grid()
```

```{r}
plot(ecdf(Groesse), lwd=2, col="lightblue", main="Verteilungsfunktion")
lines(x, pnorm(x, mean = mu, sd = sigma), lwd=2, col="red", type="l")
grid()
```

```{r}
Groesse.F = ecdf(Groesse)

# Quantile
qnorm(0.9, mean=mu, sd=sigma)

# 1-Sigma-Bereich
pnorm(mu + sigma, mean=mu, sd=sigma) - pnorm(mu - sigma, mean=mu, sd=sigma)
Groesse.F(mu + sigma) - Groesse.F(mu - sigma)

# 2-Sigma-Bereich
pnorm(mu + 2*sigma, mean=mu, sd=sigma) - pnorm(mu - 2*sigma, mean=mu, sd=sigma)
Groesse.F(mu + 2*sigma) - Groesse.F(mu - 2*sigma)

# 3-Sigma-Bereich
pnorm(mu + 3*sigma, mean=mu, sd=sigma) - pnorm(mu - 3*sigma, mean=mu, sd=sigma)
Groesse.F(mu + 3*sigma) - Groesse.F(mu - 3*sigma)
```
