This problem might sound trivial, but it is a question I have pondered on for hours without a clue how to crack it. Say, you have a series which resulted from a random process. The series is as follows: ABAAABBBBABAABBBAAABA.
How do you calculate the probability of repetition of this series?
EDIT: Each outcome is independent i.e. the events "A" and "B" are independent just as "heads" and "tails" are independent in separate coin flips.
Assuming that "probability of repetition" is referring to the probability that two consecutive entries in the sequence are identical, and that our sequence of random variables $\left( X_n \right)_{n=1}^N$ are randomly generated i.i.d. such that $\mathbb{P}(X_n = A) = p$ for any integer $1 \le n \le N$, where $0 \le p \le 1$, and that $\mathbb{P}(X_n = B) = 1-p$.
We want to find $\mathbb{P}(X_n = X_{n+1})$. There are two cases:
Case 1: $X_n = A = X_{n+1}$.
As these events are independent, we have $$\mathbb{P}(X_n = A \land X_{n+1} = A) = \mathbb{P}(X_n = A)\mathbb{P}(X_{n+1} = A) = p^2$$
Case 2: $X_n = B = X_{n+1}$
Similarly, we have
$$\mathbb{P}(X_n = B \land X_{n+1} = B) = \mathbb{P}(X_n = B)\mathbb{P}(X_{n+1} = B) = (1-p)^2 = 1 - 2p + p^2$$
Thus, as these two cases are exclusive,
$$\mathbb{P}(X_n = X_{n+1}) = \mathbb{P}(X_n = A \land X_{n+1} = A) + \mathbb{P}(X_n = B \land X_{n+1} = B) = 1-2p+2p^2$$
So our probability of repetition is $1-2p+2p^2$, where $p$ can be approximated by $\widehat{p} = \frac M N$, where $M$ is the number of $A$ values in the sample, and $N$ is the total number of values.
In the sample above, $M=11$ and $N=21$. Thus, $\widehat{p} = \frac{11}{21}$, and so we can approximate the probability of repetition as $\mathbb{P}(X_n = X_{n+1}) \approx 0.5$.