Intersection of Hamming balls of boolean vectors

844 Views Asked by At

I noticed that a similar question was asked with a little difference, an answer to this wasn't given certainly. Here is the problem: Given two Hamming balls of boolean vectors of size $n$ with centres $a$ and $b$ both with radius $r$ find the power of the set of their intersection, that is $|B(a, r)\cap B(b, r)|$ .By a boolean $n$-vector I mean a vector of length $n$ consisting only of $0$'s and $1$'s. I tried to get this number in a closed form but I think it's impossible, so the answer need not be in a closed form. And the Hamming distance between vectors $a$ and $b$ is $m$.

1

There are 1 best solutions below

9
On BEST ANSWER

Let's start with the intersection $S(a,r)\cap S(b,s)$ of two Hamming spheres. We may assume that $a$ is the zero vector and $$b = (\underbrace{1,\ldots,1}_{m\text{ times}},\underbrace{0\,\ldots,0}_{n-m\text{ times}}).$$ We want to count the vectors $v$ which are at distance $r$ from $a$ and $s$ from $b$. Distance $r$ from $a$ means that $v$ has exactly $r$ entries equal $1$. Distance $s$ from $b$ gives that if in the first $m$ entries of $b$ there are exactly $i$ zeros (i.e. exactly $m-i$ ones), in the last $n-m$ entries there must be exactly $s-i$ ones. So $(m - i) + (s-i) = r$, implying that $2i = m+s-r$. Hence $m + s - r$ is even, $i = (m+s-r)/2$ and $s - i = (s+r-m)/2$. Therefore $$\left|S(a,r)\cap S(b,s)\right| = \begin{cases}0 & \text{if }m-(s+r)\text{ odd,}\\\binom{m}{(s-r+m)/2}\binom{n-m}{(s+r-m)/2}&\text{if }m\text{ even.}\end{cases}$$

Now we get the size of the intersection of the two Hamming balls as $$\left|B(a,r)\cap B(b,r)\right| = \sum_{i=0}^r \sum_{\substack{j=0\\m+i-j\text{ even}}}^r \binom{m}{(i-j+m)/2}\binom{n-m}{(i+j-m)/2}.$$