Probability of having at least $K$ consecutive zeros in a sequence of $0$s and $1$s I have a sequence of length $N$ consisting of $M$ ones and $N-M$ zeros. I am trying to find the number of possible arrangements that produce a sequence in which there exist at least K consecutive zeros.

Any input on how to approach this is appreciated.
Let's compute $C(N,M,k)$ the number of sequences of length $N$, with $M$ zeros, and with all runs of zeros having length up to $k$. Say we have $\ell$ runs of zeroes: $z_1,z_2 \cdots z_\ell$ with $1\le z_i \le k$ , $\sum_{i=1}^\ell z_i=Z=N-M$, and $ \lceil Z/k \rceil \le \ell \le M+1$

Then $$C(N,M,k)=\sum_{\ell=\lceil M-N/k \rceil}^{M+1} c_r(M-N,\ell,k) \, c(M-\ell+1,\ell+1)$$

where $c(A,B)={A+B-1\choose B-1}$ is the number of weak compositions, and  $c_r(A,B,k)$ is the number of (strict) compositions restricted to a maximum size $k$. This later problem is solved here.
Assuming $1$s and $0$s appear independent of each other, for $M$ ones, the probability that a $1$ appears is simply $p=\frac{M}{N}$ and for $0$ is simply $1-p$. The PDF of run of $K$ consecutive $0$s can then be calculated as follows:

$$
r(K) = \left\{ \begin{array}{rl}
 p(1-p)^K &amp;\mbox{  $0\leq K\leq N$} \\
 (1-p)^K &amp;\mbox{ $K=N$}
       \end{array} \right.
$$