Another question (Bernoulli trials required for k successes) asked how many Bernoulli trials with probability $p$ of success are expected before you get $k$ successes, which is given by: $$\mathbb{E}(X)=\frac{k}{p}$$ How does this answer change if those $k$ successes are required happen within a window of size $n$? To make it concrete, here are some sequences for $k=2, n=3$:
- Success, failure, success $\to$ valid termination state
- Success, failure, failure, success $\to$ need to keep going because the two successes are not within a window of $n=3$ trials
- Success, failure, failure, success, success $\to$ valid termination state because the second and third successes are within a window of $n=3$ trials
E[# of trials] = window size / P(success within window), but that doesn't take the sliding window into account, it just assumes that each window is totally independent. – Dan Dec 02 '22 at 16:24