3

Assume a binary sequence $X = (X_t)_{t=1}^T$ such that first $1 \leq N < T$ values are ones and last $T-N$ are zeros. Now define a new sequence $Y = (Y_t)_{t=1}^T$ such that \begin{align} Y_t = \begin{cases} 0 \text{ if } X_t = 0\\ 1 \text{ with probability }p \text{ if } X_t = 1 \\ 0 \text{ with probability }1 -p \text{ if } X_t = 1 \end{cases} \end{align} i.e. Bernoulli trials over $(X_1,...,X_N)$. Now, my question is: what is the expected number of zero-runs in $Y$?

I think that the easiest way would be to count transitions $1\to0$, since \begin{align} \sum_{t=1}^{T-1}\mathbb{1}\{Y_{t-1} = 1, Y_t = 0\} = \text{number of 0 runs}. \end{align} (but that works ONLY if $Y_1= 1$). Obviously, $\mathbb{P}(Y_{t-1} = 1, Y_t = 0)=(1-p)p$, and there are $N-2+1$ possible ways to place it in the sequence $(Y_1,...,Y_N)$ (however, since $Y_{N+1} = 0$, then also $Y_N=1$ is acceptable which complicates the derivation). If there is only a single $01$, then it has to be proceeded by a sequence of zeros and followed by sequence of either zeros or zeros and then ones. This quickly becomes intractable: is there any other way to approach this problem? Hints, rather than full derivations, would be much appreciated.

EDIT: I’ve come up with the following. I can think of that $10$ subsequence as of a success in a Bernoulli trial that is performed $N-1$ times. So, the number of successes follows $\text{Binom}(N-1, p(1-p))$, but since we can have $Y_N = 1$ which automatically gives $Y_{N+1} = 0$, the result is $(N-1)p(1-p) + (1-p)$. Is it by any means true?

thesecond
  • 426
  • I get $(N-1)p(1-p)+p$. If you verify and find my result to be right, I will post it as an answer with the details. – Srini Dec 01 '25 at 18:40
  • @Srini Thank you. I get a similar result, the only difference is $1-p$ instead of $p$, which I get from not flipping the $N-$th $1$. – thesecond Dec 01 '25 at 18:45

1 Answers1

4

Let our $n$-bit string be $s = b_1,b_2,...b_n$

Note that $b_{n+1} \equiv 0$ from OP's definition.

If the first bit is $0$, it counts as a zero-run. If the first bit is $1$, it doesn't. So let's introduce a dummy bit $\color{red}{b_0 \equiv 1}$ to the left (i.e. prepend a dummy $1$). Our new string $S = \color{red}{b_0},b_1,b_2,... b_n$

For each bit, the starting of a zero-run is characterized by previous bit NOT having been flipped and the current bit is flipped. But for the $n$-th bit $b_n$, we have $b_{n-1},b_{n},b_{n+1} = 000 (\color{blue}{p^2}),010 (\color{blue}{p(1-p)}), 100 (\color{blue}{(1-p)p}),110 (\color{blue}{(1-p)^2})$ as $4$ possibilities, with the last $3$ cases adding a $1$ to the zero-run count.

The total number of zero-runs

$$ \begin{align} K &= \sum\limits_{i=1}^{n-1} P(b_{i-1}=1) P(b_{i}=0) + \color{blue}{p(1-p)+(1-p)p+(1-p)^2} \\ &= P(b_0=1)P(b_1 = 0) + \sum\limits_{i=2}^{n-1} P(b_{i-1}=1) P(b_{i}=0) + \color{blue}{p(1-p)+(1-p)p+(1-p)^2}\\ &= \color{orange}{n(1-p)p + 1 + p^2 - p} \\ \end{align} $$

To verify this formula with a brute-force method for an example of $n=5$,

$$K = 5(1-p)p + 1 + p^2 - p = \color{green}{1 + 4p - 4p^2}$$

Let's constuct the binary table for $5$ bits (without any dummy bits etc) and see if it matches.

binary table for n=5

$$ \begin{align} K(\text{brute force}) = &p^5 (1) + \\ &p^4(1-p) (2+2+2+2+1) + \\ &p^3 (1-p)^2 (2+3+2+3+3+2+2+2+2+1) + \\ &p^2 (1-p)^3 (2+3+3+2+2+3+2+2+2+1) + \\ &p (1-p)^4 (2+2+2+2+ 1) + \\ &(1-p)^5 ( 1)\\ = & \color{green}{1+4p - 4p^2} \\ \end{align} $$

Note: this is only valid when $T>n$ (OP states that $1 \le n \lt T$. So this formula is good. For $n=1$, $K=1$ as expected)

Srini
  • 2,450
  • Thanks so much! Seems I was close. One question: what about $b_n= 1$? This is not accounted for by your approach, but still can yield a run of zeros (for my notation, it would be $Y_N = 1$). – thesecond Dec 01 '25 at 20:03
  • Ah, good point, I will modify my expression for that later today, should be a simple one, likely exactly what you got – Srini Dec 01 '25 at 20:37