I have an event $A_{i, j}$, which is $A_i \cap A_j$. I have created an indicator random variable $X_{i, j}$ which is $1$ if event $A_{i, j}$ occurs and $0$ if it does not.
I then want to compute the expectation value $E(X^2)$, where $X = \sum_{i, j}^{5}{X_{i, j}}$. This is what I have so far:
$$ E(X^2) = E\left[ \left(\sum_{i, j}^{5}{X_{i, j}}\right)^2 \right] = E\left[ \left(\sum_{i, j}^{5}{X_{i, j}}\right) \left(\sum_{i, j}^{5}{X_{i, j}}\right) \right] $$
This is where I am a little confused as to what the product should be. Normally, with one index, the product would be:
$$ \left(\sum_{i=1}^{n}{X_i}\right)^2 = \sum_{i=1}^{n}{X_i^2} + \sum_{i \ne j}^{n}{X_i X_j}$$
What would be the equivalent of this for the case with two indices?
I have tried some hand calculations and come up with: $$\sum_{i, j}^{5}{X_{i, j}^2} + \sum_{i \ne j, l \ne n}^{5}{X_{i, j} X_{l, n}}$$. Does this seem correct?
We can generalize $X_{ij}$ to more than two indices as appropriate, and then $X_{ij}X_{k\ell}=X_{ijk\ell}$.
Then the product of $\sum_{i,j} X_{ij}$ with itself is the sum of all possible $X_{ijk\ell}$s.
Note $ijk\ell$ has one, two, three or four distinct numbers:
Assuming I counted these all right, the square of $\sum\limits_{i,j}X_{ij}=\sum\limits_i X_i+2\sum\limits_{i<j} X_{ij}$ equals
$$ \Big(\sum_{i,j} X_{ij}\Big)^2 = \Big(\sum_i X_i\Big)+14\Big(\sum_{i<j} X_{ij}\Big) + 36\Big(\sum_{i<j<k}\! X_{ijk}\Big)+24\Big(\!\!\sum_{i<j<k<\ell}\!\!\! X_{ijk\ell}\Big). $$