TITLE: Expected intersection size of two random sets
QUESTION [5 upvotes]: There are two sets, $A=\{a_1, \dots, a_n\}$ and $B=\{b_1, \dots, b_m\}$, for some $m$ and $n$.
The elements $a_1, \dots, a_n$ and $b_1, \dots, b_m$ are all $x$-bit binary strings, and they are all uniformly sampled from $X$, which is defined as the set of all $x$-bit binary strings. 
Let $I_{n,m}$ be the value $|A\cap B|$. Obviously, $I_{n,m}$ is a random variable.
So, how can I calculate $E[I_{n,m}]$? 
Note that $A$ and $B$ are multisets. Besides, given $x=3$, if $A$ and $B$ happen to have two $111$'s and three $111$'s, respectively ($\{111,111\}\subseteq A$ and $\{111,111,111\}\subseteq B$), then they only contribute $1$ to $I_{n,m}$.

REPLY [3 votes]: Added, in response to OP's clarification: If $A$ and $B$ are multisets, but $A \cap B$ is a set, then for the purposes of counting the size of $A \cap B$ we can treat $A$ and $B$ as if they are sets.  For example, having $1 \in A \cap B$ is equivalent to having $1$ at least once in $A$ and $1$ at least once in $B$.  This is tantamount to treating $A$ and $B$ as sets.

There are $2^x$ $x$-bit binary strings.  Since you're choosing with replacement, for any $x$-bit binary string $k$ the probability that $k \not\in A$ is $(1 - \frac{1}{2^x})^n$, so the probability that $k \in A$ is $1 - (1 - \frac{1}{2^x})^n$.  Similarly, the probability that $k \in B$ is $1 - (1 - \frac{1}{2^x})^m$.  Thus the probability that $k \in A \cap B$ is $$\left(1 - q^n \right)\left(1 - q^m\right) = 1 - q^n - q^m + q^{m+n},$$ where $q = 1 - \frac{1}{2^x}$.
Let $I_k = 1$ if $k \in A \cap B$ and $0$ otherwise.  Then $$E[I_{n,m}] = \sum_k E[I_k] = \sum_k P(k \in A \cap B) = 2^x (1 - q^n - q^m + q^{m+n}).$$