```{r, echo=FALSE}
library('exams')
include_supplement('movingaverage.num', recursive=TRUE)
library("exams.forge")
instruction <- NULL
data("EuStockMarkets")
o     <- sample(2:5, 1)
fo    <- switch(o, NA, 1/2*c(1/2, 1, 1/2), 1/3*c(1, 1, 1), 1/4*c(1/2, 1, 1, 1, 1/2), 1/5*c(1, 1, 1, 1, 1))
n     <- sample(7:15, 1)
ind   <- sample(c("DAX", "SMI", "CAC", "FTSE"), 1)
t1    <- sample(nrow(EuStockMarkets)-n, 1)
xt    <- round(as.numeric(EuStockMarkets[t1:(t1+n-1),ind]), 0)
ma    <- filter(xt, fo)
pos   <- sample(which(!is.na(ma)), 1)
#
sol      <- cbind(xt, as.numeric(ma))
row.names(sol)  <- 1:n
colnames(sol) <- c("$x_t$", "$x_t^*$")
hsol     <- html_matrix_sk(sol, title="Tag ($t$)",  fmt=rep('%.2f', ncol(sol)))
m        <- matrix(xt, ncol=1)
row.names(m) <- 1:n
colnames(m) <- ind
hxy      <- html_matrix_sk(m, title="Tag ($t$)", fmt=rep('%.0f', ncol(m)))
sc       <- num_result(ma[pos], digits=2, tolmult = 2)
```

Question
=======

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

Der Schlussstand des Aktienindex `r ind` wurde an `r n` aufeinanderfolgenden Tagen aufgezeichnet.
Berechnen Sie den gleitenden Durchschnitt der Ordnung `r o` für  $t=`r pos`$.

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

```{r, child="movingaverage.num"}
```

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