Expected number of neighboring balls in the same color Let $n$ black balls and $m$>$n$ white balls.
I arrange the balls in a row, and I want to know the expected number of black balls that one of their adjacent neighbors (right or left or both) will be black as well.
For one black ball it might be:

$p = \frac{n-1}{m+n-1} + \frac{n-2}{m+n-2}$

And for $n$ balls is

$E= p\times n$

But it doesn't make sense.
Thank you!
 A: Route:
Place a specific black ball randomly in the row and after that also place the other balls.
Let $U$ denote the event that the specific black ball is at utmost position on left or right.
Let $E$ denote the event that the specific black ball has at least one black neighbor.
Then:$$p=P(E)=P(U)P(E\mid U)+P(U^c)P(E\mid U^c)$$
Beware of the fact that $P(E\mid U)\neq P(E\mid U^c)$.
Applying linearity of expectation we find indeed $p\times n$ as final answer.
A: Here is my approach which agrees with the answer provided by @drhab
Arrange the $n$ black balls and $m$ white balls in a random order.
Take $X_i=1$ if the $i^{\text{th}}$ ball is black and has at least one black neighbor and $X_i=0$ otherwise.
Note $X_1=1$ if and only if the first two balls in this random arrangement are black. This occurs with probability $\frac{n(n-1)}{(m+n)(m+n-1)}$. By symmetry we have $$\mathbb{P}(X_1=1)=\mathbb{P}(X_{m+n}=1)$$
Meanwhile $X_2=0$ if and only if one of the two events happen.

*

*The second ball is white.

*The first ball is white, the second ball is black, and the third ball is white.

This suggests $$\mathbb{P}(X_2=0)=\frac{m}{m+n}+\frac{mn(m-1)}{(m+n)(m+n-1)(m+n-2)}$$
Using linear of expectation, $$\begin{eqnarray*}\mathbb{E}\left(\sum_{i=1}^{m+n} X_i\right) &=& 2\mathbb{P}(X_1=1)+(m+n-2)\left[1-\mathbb{P}(X_2=0)\right] \\ &=& \frac{n\left(2m+n\right)\left(n-1\right)}{\left(m+n\right)\left(m+n-1\right)}\end{eqnarray*}$$
