```{r data generation, echo = FALSE, results = "hide"}
library("exams")
library("exams.forge")
instruction <- NULL 
include_supplement("bivariate_discrete.num", recursive=TRUE)
sxopy <- 'X+Y'
repeat {
  x    <- sort(sample(0:6, 2))
  y    <- sort(sample(0:5, 3))
  xopy <- outer(x, y, '+')  
  val  <- as.vector(xopy)
  if (length(unique(val))<5) break
}
#
px  <- ddiscrete(runif(length(x)))
py  <- ddiscrete(runif(length(y)))
pxy <- ddiscrete2(px, py, zero=TRUE)
colnames(pxy) <- y
rownames(pxy) <- x
#
p      <- incomplete_table(pxy, 7)
pfull  <- attr(p, "full") 
colnames(p) <- c(sprintf("Y=%.0f", y), "$\\sum$")
rownames(p) <- c(sprintf("X=%.0f", x), "$\\sum$")
hp <- html_matrix_sk(p, "", fmt=rep("%.2f", 4))
colnames(pfull) <- c(sprintf("Y=%.0f", y), "$\\sum$")
rownames(pfull) <- c(sprintf("X=%.0f", x), "$\\sum$")
hpf <- html_matrix_sk(pfull, '', fmt=rep("%.2f", 4))
colnames(xopy) <- sprintf("Y=%.0f", y)
rownames(xopy) <- sprintf("X=%.0f", x)
hxopy <- html_matrix_sk(xopy, math(sxopy), fmt=rep("%.0f", 3)) 
v     <- sample(val, 1)
pv    <- as.matrix(tapply(pxy, xopy, sum))
colnames(pv) <- sprintf("$P(%s=v)$", sxopy)
hpv    <- html_matrix_sk(pv, '$v$', fmt="%.2f")
ptype  <- "prob"
sc     <- num_result(as.numeric(pv[as.character(v),1]), 3)
```

Question
========

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

Gegeben sei eine unvollständige Wahrscheinlichkeitsfunktion für zwei diskrete Zufallsvariablen $X$ und $Y$ (NA=kein Eintrag):

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

Berechnen Sie $P(`r sxopy`=`r v`)$.

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

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