Consider a binary string of length $n \geq 2$. An edit operation is a single character insert, delete or substitution. The edit distance between two strings is the minimum number of edit operations needed to transform one string into the other one. Given a string $S$, my question relates to the number of distinct strings of length $n$ which are edit distance $2$ from $S$.
Let us write $f_2(S)$ for the number of distinct strings of length $n$ which are edit distance $2$ from $S$.
Let $X_n$ be a random variable representing a random binary string of length $n$, with the bits chosen uniformly and independently. My question is what is:
$$\mathbb{E}(f_2(X_n))\;?$$
For small $n$ we can compute the value exactly:
- $\mathbb{E}(f_2(X_2)) = 1$.
- $\mathbb{E}(f_2(X_3)) = 3 \frac{1}{4}$.
- $\mathbb{E}(f_2(X_4)) = 7 \frac{1}{8}$.
- $\mathbb{E}(f_2(X_5)) = 12 \frac{13}{16}$.
- $\mathbb{E}(f_2(X_6)) = 20 \frac{13}{32}$.
- $\mathbb{E}(f_2(X_7)) = 29 \frac{61}{64}$.
- $\mathbb{E}(f_2(X_8)) = 41 \frac{61}{128}$.
- $\mathbb{E}(f_2(X_9)) = 54 \frac{253}{256}$.
- $\mathbb{E}(f_2(X_{10})) = 70 \frac{253}{512}$.
See What is the expected number of distinct strings from a single edit operation? for a related question about edit distance 1 which has a very clean and simple solution.