```{r, echo=FALSE}
library("exams")
library("knitr")
include_supplement("pearson.num", recursive=TRUE)
library("exams.forge")
instruction <- NULL
data(sos100, package = "exams.forge.data")
n     <- sample(4:8, 1)
rseq  <- seq(-0.95, 0.95, by=0.05)
r     <- sample(rseq, size=1, prob=rseq^2)
xy0   <- pearson_data(r=r, nmax=n, n=100, xsos=sos100)
xy    <- 10+xy0
sc    <- num_result (cor(xy[,1], xy[,2]), digits = 3, tolmult = 2)
sol   <- rbind(t(xy), t(xy0), t(xy0^2), xy0[,1]*xy0[,2])
sol   <- cbind(sol, rowSums(sol))
colnames(sol) <- c(sprintf("%0.f", 1:n), "Summe")
row.names(sol) <- c("$x_i$", "$y_i$", "$x_i-\\bar{x}$", "$y_i-\\bar{y}$",  "$(x_i-\\bar{x})^2$", "$(y_i-\\bar{y})^2$",  "$(x_i-\\bar{x})(y_i-\\bar{y})$")
hsol  <- html_matrix_sk(sol, title='', fmt=rep("%.0f", n+1))
m     <- rbind(xy[,1], xy[,2])
colnames(m) <- 1:n
row.names(m) <- c("Punkte in Mathematik", "Punkte in Statistik")
hxy <- html_matrix_sk(m, title="Schüler", fmt=rep("%.0f", n))
```


Question
========

```{r, error=TRUE, child=instruction}
```

Von `r n` ausgewählten Schülern wurden die Punkte in der Mathematik- und Statistik-Klausur notiert. Berechnen Sie den Bravais-Pearson-Korrelationskoeffizient. 

```{r, echo=FALSE, results='asis'}
cat(toHTMLorLatex(hxy))
```


```{r, child='pearson.num'}
```

Meta-information
================
extype: num
exsolution: `r sc$fx[1]`
extol: `r sc$tolerance`
exname: `r knitr::current_input()`


