How to prove the sign test Please correct me if I'm wrong, but a version of the sign test assumes under $H_0$ that there is some distribution $F$ where $X_i \sim F, Y_i \sim F$ and $X_i, Y_i$ are iid. Then it states that $T = \#\{x_i > y_i\}$ follows a binomial distribution $B(m, 0.5)$ where $m = \#\{x_i \ne y_i\}$.
The fact that $T$ follows a binomial distribution is intuitive (I can see that $\Pr(X_i < Y_i) = \Pr(Y_i < X_i)$ by symmetry), but how do you justify this formally?
 A: First let's prove the statement that $p:=P(X_i < Y_i) = P(Y_i < X_i)$. In order to prove this statement we will not need to assume that  $q:=P(X_i=Y_i)=0.$
Let $F$denote the common distribution function of $X_i$ and $Y_i$. Then one direction is
$$P(X_i<Y_i)=E[P(X_i<Y_i|Y_i)]=$$$$=\int_{-\infty}^{+\infty}P(X_i<y|Y_i=y)dF(y)=\int_{-\infty}^{+\infty}P(X_i<y)dF(y)=$$
$$=\int_{-\infty}^{+\infty}F(y)dF(y).$$
(The condition could be deleted because of the independence.)
The other direction is very similar:
$$P(Y_i<X_i)=E[P(Y_i<X_i|X_i)]=$$$$=\int_{-\infty}^{+\infty}P(Y_i<x|X_i=x)dF(x)=\int_{-\infty}^{+\infty}P(Y_i<x)dF(x)=$$
$$=\int_{-\infty}^{+\infty}F(x)dF(x).$$
(The condition could be deleted because of the independence.)
Obviously
$$\int_{-\infty}^{+\infty}F(y)dF(y)=\int_{-\infty}^{+\infty}F(x)dF(x).$$

Let's  see how to use the sign test. There are two possibilities: either $q=0$ or $q>0$. The first case is not interesting. Then the probability that for some of the sample pairs $X_i=Y_i$ is an event of zero probability.
If $q>0$ then we omit from the sample those pairs for which $X_i=Y_i$. Then we are interested in the following question:
$$P(X_i>Y_i|X_i\not = Y_i)=P(Y_i>X_i| X_i\not = Y_i)=\frac{1}{2} \text{ ? }$$
The answer is yes.
Obviously
$$P(X_i>Y_i|X_i \not = Y_i)=\frac{P(X_i>Y_i \cap X_i \not = Y_i)}{1-q}=\frac{p}{1-q}.\tag 1$$
Obviously again 
$$1=P(X_i>Y_i)+P(Y_i>X_i )+P(X_i  = Y_i)=2p+q.$$
So $$q=1-2p \tag 2.$$
Comparing $(1)$ and $(2)$ we get 
$$P(X_i>Y_i|X_i\not = Y_i)=\frac{p}{1-q}=\frac{p}{1-(1-2p)}=\frac{1}{2}.$$

So, when we perform an experiment (described in the OP) and calculate the following relative frequency 
$$\frac{\#\{X_i > Y_i\}}{\#\{X_i \ne Y_i\}}=\frac{T}{m}\approx \frac{1}{2}$$
then we perform and experiment corresponding to a binomial random variable of parameters $m$ and $\frac{1}{2}$. This is certainly  true if $X_i,Y_i$ are iid. We may suspect that this is not the case if $\frac{T}{m}$ is far from $\frac{1}{2}$ even if the size of the filtered sample is large enough.
