In one of their recent podcast episodes, the Data Science Imposters discussed the prisoner’s dilemma. It goes like this:

Andy and Bon (that’s me) commit a crime. Not anything terrible, just something gently bad. (No sense in killing folks for a blog post, right?)

We get caught. (I know – it gets worse!) And they separate us into two rooms for interrogation.

The detective says to me, “If you confess, you may get some leniency.”

**Bon**: Just how much of this “leniency” can I get?

**Detective**: Well, if you both both confess, you both get reduced sentences of 5 years.

**Bon**: What if I don’t confess?

**Detective**: You get 10 years, if Andy confesses.

**Bon**: What if Andy stays quiet?

**Detective**: That’s the great part. If he keeps quiet and you confess, you get NO time!

**Bon**: But what if we both refuse to confess?

**Detective**: We have your DNA, so you automatically get 3 years each.

### What should I do?

The Data Science Imposters gave the classic solution:

Suppose I have an attorney and he’s somehow in the know. If he comes and says, “**Andy confessed**,” what should I do?

- If I stay quiet, I will do 10 years.
- If I confess, I’ll do 5 years.

So if Andy confesses, I will too, so I only get 5 years.

But what if Mr. Know-it-all-attorney comes to me with, “He’s sticking to his guns – **Andy is NOT confessing**!”

- If I stay quiet, I will do 3 years.
- If I confess, I’ll do 0 years.

Again, if Andy zips his lips, it’s still far better for me to confess.

Either way, I confess.

### I can decide with probability and expected values.

I’ve been teaching *expected value* in my statistics class these past few weeks, so I began to think of the problem from that perspective.

Suppose I **don’t** know what Andy is doing. And since Andy is flaky, it’s a total coin toss on what he’ll do. In other words, the probability of him doing either is 0.5.

Let’s say I choose to be a loyal friend (maybe he saved my mom from a crazed escaped alligator from the zoo). So **I’m going to stay quiet**.

We can assign a *random variable X* to the outcomes of what Andy chooses (as his are totally random):

- If Andy chooses to confess, the random variable
*X*= -10 (ten years hard time for me). - If Andy chooses to stay quiet,
*X*= -5 (only 5 years in the big house).

Since each of these are equally likely, the *expected value* of the random variable *X* is the average: -7.5.

On the other hand, let’s say Andy gets on my nerves and I saw him spit in my mom’s alligator gumbo once. So **I choose to rat on him**.

We assign the random variable *Y* to the outcomes like this:

- If Andy chooses to confess, the random variable
*Y*= -3 (a 3 year sentence). - If Andy chooses to stay quiet,
*Y*= 0 (I get off scott free!).

Again, these are equally likely, so the expected value is the average: -1.5.

### Do I still confess?

One way to determine if you should play a game is by examining the expected value. If you play the game a bazillion times, the expected value is what you’ll win on average for each game.

In the game of what-will-Andy-do, the expected value of my confession (1.5 years in prison) is better for me than the expected value of staying quiet (7.5 years).

So I’ll still confess.

### But what about loyalty?!

Where there are humans, there is variability. The reality is that my partner in crime could be known for being a snitch or being very loyal. Let’s do some crimes with two other people: Charlie and Dean.

Charlie is a great friend. But not only that, out of the 10 times he’s been in police custody, only 1 time did he turn on his partner.

Empirically, the probability that he will confess is 0.10. And the probability that he will stay quiet is 0.90.

If **I stay quiet**, and Charlie chooses to

- Confess, then
*X*= -10 with*P(X)*= 0.10. - Stay quiet, then
*X*= -5 with P(X) = 0.90.

So the expected value is

If **I confess**, and Charlie chooses to

- Confess, then
*Y*= -5 with*P(Y)*= 0.10. - Stay quiet, then
*Y*= 0 with*P(Y)*= 0.90.

Sadly, even with a super loyal friend, I should still turn him in!

### How about that weasel, Dean?

Dean has been in police custody 10 times and 7 of those he’s thrown his partner under the bus.

Empirically, the probability that he will confess is 0.70. And the probability that he will stay quiet is 0.30.

If **I stay quiet**, and Dean chooses to

- Confess, then X = -10 with P(X) = 0.70.
- Stay quiet, then X = -5 with P(X) = 0.30.

So the expected value is

If **I confess**, and Dean chooses to

- Confess, then Y = -5 with P(Y) = 0.70.
- Stay quiet, then Y = 0 with P(Y) = 0.30.

As suspected, I still should confess, but maybe with Dean I do so very quickly!

*Share your thoughts in the comments, on Twitter or on Facebook.*

*The Data Science Imposters podcast is one of my very favorites. Jordy and Antonio offer just the right amount of intelligent self-depreciation balanced with great information. I highly recommend them!*

### You might also like:

- 20 Challenging Puzzle Types
- Math Puzzle Inventing – Can You Do It?
- The Tower of Hanoi Math Game
- 8 Digit Puzzle

This post may contain affiliate links. When you use them, you support us so we can continue to provide free content!

I LOVE this thought experiment! When I come across it, I find myself wondering what certain people who pop into my head would decide if I was in that predicament. There is a team/trust building exercise similar to this that relies on everyone considering the greater good. Just did a search online but came up empty. I’ll have to talk with Bon to see if we can find it and maybe she could do a follow-up on this post.