I have a vector of one's and zero's of length n with a probability p of observing a one and 1-p of observing a zero. I slide a (overlapping) window of size $k$ across this vector and take the sum (which can take values $0\dots k$). What is the probability of observing a particular sum?
My specific problem uses $n=1000000$, $p=0.995$, $k=3$ and this is what I'm mostly interested in, however a general solution would be nice.
I've enumerated the different possibilities that give rise to each sum for $k=3$, i.e. $$p^3 + (2p+1-p)*3 + (p+2(1-p))*3 + (1-p)^3 = 1$$ but does the fact that the sliding windows are overlapping change the probabilities?
I suspect your calculation $$p^3 + (2p+1-p)^3 + (p+2(1-p))^3 + (1-p)^3$$ should be instead $$\sum_{i=0}^k \Pr[\mbox{sum}=i]=\sum_{i=0}^k \binom{k}{i} \,p^i (1-p)^{k-i}= p^3 + 3p^2(1-p) +3p(1-p)^2 + (1-p)^3$$