In this article, the winner of the math competition answered this question correctly:

In a barn, 100 chicks sit peacefully in a circle. Suddenly, each chick randomly pecks the chick immediately to its left or right. What is the expected number of unpecked chicks?

The answer was given as 25. I am interested to know the correct method for solving this problem as well as a general way to find this out for N chicks. I was thinking of trying to solve by figuring out the number of occurrences of (something?) inside a binary string of length 100 (or N), but I don’t know if that is the right way to approach it.

**Answer**

For any individual chick, there is a 0.5 chance that the one on its right won’t peck it, and a 0.5 chance that the one on its left won’t peck it. So overall, it has a 0.25 chance of not being pecked.

Since this is true for every chick, we can add up 0.25(100)=25 to get the number of unpecked chicks.

“But wait,” you might say, “the probabilities that chicks are unpecked aren’t independent! If chick n is unpecked, then chicks n−2 and n+2 will be pecked. Surely we have to take this into account!”

Fortunately, there’s a very useful theorem called **linearity of expectation**. This tells us that for **any** random variables X and Y, independent or not, E[X+Y]=E[X]+E[Y], where E is the expected value. What we’re formally doing above is assigning a random variable Xi to the ith chick that is equal to 0 if the chick is pecked and 1 if it’s unpecked. Then the total number of unpecked chickens is ∑Xi, so the expected number of unpecked chickens is

E[∑Xi]=∑E[Xi]

by linearity of expectation. But E[Xi] is just the probability that the ith chicken is unpecked, thus justifying our reasoning above.

**Attribution***Source : Link , Question Author : AAC , Answer Author : Carmeister*