Random sequence of $0$'s and $1$'s - what is the average 'in a row' succession

245 Views Asked by At

Let's say we create a sequence from coin tossing. Heads will be signified as $0$ and tails as $1$

Let's define $R$ as a successive elements(in the given sequence) of the same value.

for example we have the sequence:

$0,0,1,0,0,0,0,1,0,1,1,0$

In the given sequence there are total of $7$ different $R$'s

My question is simple: Let's say we have infinite sequence - what is the average length of $R$ (length = how many elements are in $R$). in the above case is $12/7$

equivalent question would be how may times there is element switch in the sequence(also = how many different $R$'s - 1)'s.for example in a sequence in the length of $100$ , if there are $24$ elements switch that means we have $25$ $R$'s - so the average length is $4$.

I would be also interested in the entire distribution of $R$'s length.

probably I am short of the appropriate terminology to get answer in the internet.

2

There are 2 best solutions below

0
On BEST ANSWER

Each element has a fifty percent chance of starting a new R, so half of them will start new Rs. The first one certainly will, so the average number will be $(N+1)/2$
The distribution of $R$ will be one more than a binomial random variable, R-1~B(N-1,1/2)

0
On

We consider sequences of fixed length $n$. You are looking for the number of runs. The technical term will help in searching. There is a large literature.

For $i=1$ to $n$, let $X_i=1$ if a run begins at position $i$, and let $X_i=0$ otherwise. Then the number $Y$ of runs is given by $Y=X_1+X_2+\cdots+X_n$.

By the linearity of expectation, we have $E(Y)=E(X_1)+E(X_1)+\cdots +E(X_n)$.

We have $E(X_1)=1$. For any $i\gt 1$, we have $\Pr(X_i=1)=\frac{1}{2}$. It follows that $$E(Y)=1+(n-1)\cdot\frac{1}{2}=\frac{n+1}{2}.$$

Remark: In this case, the answer is reasonably clear without calculation. We used the Method of Indicator Random Variables because it is so often useful.