Finding the expected value of coin flip experiment (Dark Souls problem)

Let's reformulate the problem in an equivalent and simpler way:

We have a sequence of independent realizations of a discrete random variable $Y$, taking values on $1, 2 \cdots, n , n+1$, with a given pmf $q_i = P(Y=i)$. We win a round each time $Y=n+1$.

( In the original formulation $Y$ corresponds to the first coin that "failed" (tail), or either $Y={n+1}$ if we won. Hence

$$ q_i = \begin{cases} (1-f_i)\prod_{j=1}^{i-1}{f_j} & \quad 1\le i \le n \\ 1 - \sum_{i=1}^n (1-f_i)\prod_{j=1}^{i-1}{f_j} & \quad i = n+1 \end{cases} \tag1 $$

gives the relationship between $q_i$ and $f_i$. Moreover, $q_i$ corresponds to $x$ in OP's attempt).

For each round, we mark the longest immediately previous non-decreasing subsequence (perhaps empty), and count each value of $Y$.

Take for example, $n=5$, and a particular sequence: $$\cdots 4 \, \color{green}{2 \, 3 \,4 \,4} \,\color{red}{6} \,5\, 3\, \color{green}{1\, 1\, 5} \,\color{red}{6} \, \color{red}{6}\, 3\, 4 \cdots \tag2$$

Each red number signals a finished round, and each inmediate previous non-decreasing sequence (in green) denotes the counted values (coins).

Hence, in the three completed round here: we have ${\bf x}=(x_1,x_2,x_3,x_4,x_5)= (0,1,1,2,0)$ for the first round, ${\bf x}=(2,0,0,0,1)$ for the second and ${\bf x}=(0,0,0,0,0)$ for the last one (empty counters). We want to calculate $E[x_i]$.


( Edit - see below for a simpler and better proof)

Imagine a long sequence of length $m$. In average we'll have $q_6 m$ completed rounds.

Let $\alpha_{k,5}$ count the number of rounds with $x_5=k$ ($0\le k < \infty$). Again, in average we'll have $$\alpha_{k,5} = m \, q_6 \, q_5^k(1-q_5) \tag3$$

Hence the approximation (asympotically exact, I conjecture) $p(x_5 = k) = q_5^k (1-q_5)$ and $$E[x_5]= \frac{q_5}{1-q_5} \tag4$$

Similarly, for $\alpha_{k,4}$ we can sum over $j$, the number of intermediate $5's$ and

$$\alpha_{k,4} = \sum_j m \, q_6 \, q_5^j q_4^k(1-q_4) \tag5$$ and $$E[x_4]= \frac{q_4}{(1-q_5)(1-q_4)}$$

Then, in general

$$E[x_i]= \frac{q_i}{\prod_{j=i}^n(1-q_j)} \tag6$$


Edit: Another proof: Let's compute, for example, $p(x_3) = P(x_3 = x_3)$ , i.e., the probability that the most recent non-decreasing sequence before a given $6$ (and excluding the previous $6$) includes $x_3$ $3$'s. For $x_3 \ge 1$ this is given by

$$ p(x_3) = \sum_{x_5, x_4} (1-q_3) q_3^{x_3} q_4^{x_4} q_5^{x_5}= \frac{(1-q_3)}{(1-q_4)(1-q_5)} q_3^{x_3} \tag7$$

Now, because $\sum_{k=0}^{\infty} k a^k=\sum_{k=1}^{\infty} k a^k=a (1-a)^{-2}$, the expected value is:

$$E[x_3]= \frac{q_3}{(1-q_5)(1-q_4)(1-q_3)} \tag 8$$

in agreement with $(6)$.


Some values, in agreement with numerical simulation:

 i       1       2       3       4       5
   
 f      0.5     0.5     0.5     0.5     0.5
 q    0.50000 0.25000 0.12500 0.06250 0.03125
E[x]  1.67783 0.41946 0.15730 0.06882 0.03226
   
 f      0.9     0.7     0.5     0.3     0.1
 q    0.10000 0.27000 0.31500 0.22050 0.08505
E[x]  0.31155 0.75707 0.64477 0.30917 0.09296
   
 f       0.1     0.3     0.5     0.7     0.9
 q     0.90000 0.07000 0.01500 0.00450 0.00105
E[X]   9.87958 0.07684 0.01531 0.00453 0.00105