I am in interested into the following problem. We are given an alphabet $\Sigma$ of $k$ letters and a fixed string $S_1$ of length $l$ defined over $\Sigma$. Given a probability distribution $D$, we sample another string $S_2$ from the set of possible strings defined over $\Sigma$ and with exactly length $n$. What is the probability that $S_1$ is a substring of $S_2$? Additional assumptions could be made about D. For a uniform distribution, it is a combinatoric problem which solution has been studied for example in: https://stackoverflow.com/questions/6790620/probability-of-3-character-string-appearing-in-a-randomly-generated-password Would you please have any insight about how it generalizes to any distribution of mean $\mu$ and standard deviation $\sigma$?