Expected Hamming distance

1.7k Views Asked by At

I choose two code words independently at random from $\mathbb F_2^n$ where each string has $n$ binary digits equally likely. $\mathbb F_2$ represens the binary digits.

The Hamming distance is between two vectors $x,y\in\mathbb F_2^n$ is the number of places where they differ: $d(x,y)=|\{j:x_j\not = y_j\}|$

How can I evaluate the expected distance then?

2

There are 2 best solutions below

2
On BEST ANSWER

In effect you’re choosing one word at random and asking for its expected distance from the zero word. That’s clearly $n/2$: every word at distance $k$ has a word at distance $n-k$ as its complement.

1
On

Nothing wrong with Brian's answer. Just adding a different way of looking at it. This has the advantage of being perhaps easier to generalize to alphabets larger than $\{0,1\}$.

The expected contribution (to the Hamming distance) of bit number $i$ is clearly $1/2$. After all, the contribution is either zero or one, and both are equally likely. Now the Hamming distance between two vectors is the sum of the contributions of individual bits. And the expected value of their sum is the sum of the expected values. As there are $n$ bits, this gives $n/2$ as the answer.