Computing an expectation based on accuracy of future data as a random variable for a binary classifier. I am reading Peter Flach's introduction to machine learning and the following paragraph p.345 (top of the page) here for measuring the performance of a binary classifier.

In machine learning the situation is usually more concrete, and our
  experimental objective – accuracy, say – is something we can measure
  in principle, or at least estimate (since we’re generally interested
  in accuracy on unseen data). However, there may be unknown factors we
  have to account for. For example, the model may need to operate in
  different operating contexts with different class distributions. In
  such a case we can treat accuracy on future data as a random variable
  and take its expectation, assuming some probability distribution over
  the proportion of positives pos. Since $acc = pos·tpr + (1 − pos)·tnr$
  where (tpr = true positive rate, tnr = true negative rate), and
  assuming we can measure true positive and negative rates independently
  of the class distribution, we have (assuming a uniform distribution
  over pos)

$\mathbb{E}[acc] = \mathbb{E} [pos·tpr +(1−pos)·tnr]
= \mathbb{E}[pos]tpr+E[1-pos]tnr = tpr/2+tnr/2$.
I do not understand this statement. What is the relationship between the proportion of positives and the random variable (the accuracy of the model)? Any insights appreciated.

They are using the total law of probability,
\begin{align}\mathbb{E}[acc] &=\mathbb{E}[acc|pos]Pr(pos)+ \mathbb{E}[acc|neg]Pr(neg)\\
&=tpr\cdot \frac12 + tnr\cdot \frac12\end{align}
They assume the proportion of positive and negative data to be both $\frac12$.
If we know the data comes from the positive class, the accuracy out of that class is known as tpr. Similarly for tnr. 
