Circle of Chicks
Lee Phillips
May 15th, 2017

Today’s New York Times contains an article about a mathematics contest for young people. One of the problems concerns 100 baby chicks arranged a circle. Chicks being chicks, each one decides to peck one of its neighbors. It must decide to peck either the one on its left or the one on its right, and it must peck one and only one. The choice of whether to harass the neighbor on the left or on the right is made randomly; “right” and “left are equally likely.

The question is: what is the expected number of chicks that escape without being pecked?

This is a straightforward and elementary problem in probability theory, not one of those notorious mind-benders that the theory offers in abundance. Nevertheless, it’s a sure thing that some people will be surprised at the result. If you’ve studied this area of mathematics, you probably know how to calculate the answer; if not, this article will serve as an introduction to a subject that everyone should know something about — not only because it is immensely useful, but because it is a lot of fun.

If you have a number of equally likely possible results, then the probability of getting any one of them is 1/N, where N is the number of possible results. So, if you have a normal, 6-sided die, and you throw it, the probability of getting a three, or a five, or any of the six possible numbers is 1/6.

You can also calculate the probabilities of certain combinations of events. The probability of a number of independent events is the product of the probabilities of each individual event. In probability theory, independent events are those that don’t influence each other: one having occurred does not change the probability of the others happening. If you throw two dice, the probability of getting snake eyes (a one on each die — and if you didn’t know that, you need to get out more) is the probability of getting a one on the first die multiplied by the probability of getting a one on the second die, or 1/6 × 1/6 = 1/36. The probability is the same for any particular combination: a one and a three, two sixes, etc.

The contest problem asks about an “expected” number. There is a very important concept in probability theory, called the expectation value; the problem is referring to that. If you repeat some process that results in a random result a large number of times, the expectation value is the average of the result. It can be the average of doing whatever it is over and over a large number of times, or doing a large number of experiments all at the same time. The average will be the same, if each process in independent of the others.

The expectation value is behind the admonition that it is a bad idea to play the lottery. Lotteries only exist because the operator (usually a state government) knows that it is a sure way to make money; this means, necessarily, that the players will lose money on average. If a ticket costs \$1, and the prize is \$1,000, but the probably of winning the prize is 1/2,000, then the expectation value of your earnings is 50¢: you lose half your dollar on average (if you play a large number of times). You calculate this by multiplying the probability of winning by the amount of the jackpot. (The calculation is correct as far as it goes. But the conclusion that it is therefore irrational in every case to play the lottery does not follow, because it ignores the nature of the marginal utility of money. But that is a different subject entirely.)

Now, what about our chicks? The question is, what is the expected value of the number of chicks are are not pecked? Imagine yourself small, fuzzy, and a part of this diabolical experiment. There are four possible outcomes for you: you could be pecked by both of your neighbors, pecked only be the one on the left, attacked only by the one on the right, or escape completely unscathed. The probability of being pecked by your neighbor on the left is 1/2, because can choose you or its other neighbor with equal probability, and it must choose one. Likewise for your neighbor on the right. It should be clear that the probability of not being pecked by left chick = 1/2 as well, and likewise for right chick. To escape being pecked at all, you must be not pecked by both neighbors, and the combined probability of this is 1/2 × 1/2 = 1/4.

Since the probability of any given chick to escape without getting pecked is 1/4, as we now know, then, since there are 100 chicks, the expected number of unpecked chicks is 1/4 × 100 = 25. That’s the answer!

The young man in the article arrived at this answer in less than a second, which I think is quite remarkable. This stuff is as familiar to me as arithmetic, but, unless I had recently worked on a very similar problem very recently, there is no way I would be able to come up with the answer that quickly. And outside of contests, which are of dubious value, that kind speed is not really important. So think nothing of it if it took you much longer to figure it out.

Do you find it hard to believe that 25 out of the 100 chicks will emerge unpecked? Were you expecting something else? Perhaps we made a mistake, or maybe there’s even something wrong with probability theory, or the way we are applying it to the situation. We can check our answer by doing the experiment! Not with actual chicks — that would be messy, and we don’t know if we can reproduce the assumptions of the problem in real life. Perhaps baby chickens have an innate preference for pecking to the left, for example.

This is what computers are for. Let’s make a computational version of the problem, using the Python programming language:

``````from random import randint, seed
seed(17)
c = *100
output = open('chickresults', 'w')
ntrials = 100
total = 0
for trial in range(ntrials):
for chick in range(len(c)):
c[chick] = randint(0, 1) + randint(0, 1)
result = len([a for a in c if a == 0])
total = total + result
output.write("%s, %s\n" % (trial, result))
output.write('average of %s trials = %s' %\
(ntrials, total/ntrials))``````

This makes a list with 100 numbers, representing the chicks. The value of each element is how many times that chick has been pecked. We start with 100 zeroes, because everything starts out peacefully. Of course, that won't last long. We go through the list, and randomly either peck it or not, twice for each element, adding the two possible pecks together. When we are done, we put the number of remaining zeroes into the variable `result`, and write it to a file. We go through all this 100 times, writing the results of each experiment to the file, then, when we’re all done, take the average of all the results. Here is the output (split into columns):

``````0, 25      26, 26    51, 29    76, 25
1, 20      27, 30    52, 24    77, 17
2, 24      28, 30    53, 24    78, 24
3, 28      29, 29    54, 23    79, 22
4, 20      30, 28    55, 30    80, 16
5, 27      31, 26    56, 22    81, 28
6, 25      32, 27    57, 29    82, 29
7, 31      33, 21    58, 26    83, 23
8, 26      34, 22    59, 26    84, 24
9, 24      35, 26    60, 23    85, 25
10, 27     36, 33    61, 18    86, 24
11, 22     37, 24    62, 24    87, 32
12, 26     38, 19    63, 22    88, 16
13, 17     39, 29    64, 30    89, 26
14, 26     40, 18    65, 32    90, 26
15, 32     41, 23    66, 25    91, 30
16, 26     42, 24    67, 24    92, 21
17, 37     43, 24    68, 20    93, 26
18, 17     44, 27    69, 24    94, 20
19, 21     45, 21    70, 20    95, 24
20, 19     46, 24    71, 34    96, 29
21, 24     47, 26    72, 27    97, 29
22, 25     48, 23    73, 23    98, 23
23, 27     49, 22    74, 23    99, 29
24, 31     50, 27    75, 29    average of 100 trials = 24.94
25, 19``````

As you can see, some of the results are pretty far from the expected value of 25, but that’s randomness for you. The average of all the experiments is, however, very close to what we expect. If you want to copy this code and try it yourself, you can change the `seed` to something else to get a different sequence of pseudorandom numbers.

Comments are handled through email. Please send mail to _chicks_comment@lee-phillips.org if you would like me to include it here. I will never expose your email address. Let me know if you want me to hide your name, as well.

From: Petar Tsankov

Date: Thu, 25 May 2017

Elegant solution using exact probabilistic programming solvers like http://psisolver.org

``````===chicks.psi===
NUM_CHICKS := 10;

def main() {
peck_right := array(NUM_CHICKS,0);
for i in [0..NUM_CHICKS) {
peck_right[i] = flip(1/2); // peck_right[i] = true means chick i pecks the right one, otherwise it pecks the left one
}
pecked := 0;
for i in [0..NUM_CHICKS) {
if (peck_right[(i-1) % NUM_CHICKS] == 0 || peck_right[(i+1) % NUM_CHICKS] == 1) {
pecked += 1;
}
}
return Expectation(NUM_CHICKS - pecked);
}
===END CODE===``````

Running psi chicks.psi returns the precise correct answer: 5/2 out of the 10 chicks are not pecked ;)

• Petar

That is a fascinating project. Thank you for the excellent introduction by way of an example.

lee-phillips.org is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.