[Math] Probability that the dot product of two binary vectors is $0$ or $1$

probabilityprobability distributions

I have two binary vectors $f$ and $r$. Elements of $r$ are drawn from uniform random distribution, while elements of $f$ are drawn from a Bernoulli distribution with parameter $p$ (so $i^{th}$ element of $f$ is $1$ with probability $p$). How would I calculate the probability that $f \cdot r \equiv0\text{ mod }2$?

Best Answer

Note that the $f_{i}r_{i}$ are Bernoulli distributed with parameter $\alpha:=P\left\{ f_{i}=1\right\} P\left\{ r_{i}=1\right\} =\frac{p}{2}$.

That implies that $f.r=f_{1}r_{1}+\cdots+f_{n}r_{n}$ is binomially distributed with parameters $\alpha$ and $n$.

This leads to $P\left\{ 2\mid f.r\right\} =\sum_{k=0}^{\lfloor\frac{n}{2}\rfloor}\binom{n}{2k}\alpha^{2k}\left(1-\alpha\right)^{n-2k}$ for $\alpha =\frac{p}{2}$.