twenty
$\begingroup$

The problem is as in the title, where assume optimal play in the second round to maximize number of heads (so in the second round we do not reflip coins with heads in the first round).

I know how to solve it by conditioning on the first outcome (the number of heads in the first round of the game). However, it ultimately leads to some binomial sums with binomials.

Intuitively, I expect 4 heads on first flip, then I have 4 coins left which I flip and expect 2 heads from in the second round. In total, I get 6 heads. Is it possible to justify this line of reasoning formally?

$\endgroup$
ten
  • $\begingroup$ If you are allowed to flip as many coins as you want, why wouldn't you flip all eight ? $\endgroup$ May 2 at 3:20
  • seven
    $\begingroup$ @trueblueanil I should have been more precise,m you want to maximize amount of heads optimally. so on second round you flip non heads $\endgroup$
    –  Sorfosh
    May 2 at 3:21
  • one
    $\begingroup$ I could be mistaken; I don't think that any shortcut line of reasoning such as you suggest is valid. Personally, I would automatically use the method described in the first paragraph of your posted question. In fact, I can't imagine any other method giving an exact answer. $\endgroup$ May 2 at 3:27
  • four
    $\begingroup$ If you are allowed to reflip only from the coins that showed tails in the first round, and you are permitted only two rounds, obviously you should flip all of the coins that showed tails. I am not understanding what else you mean by optimal play $\endgroup$ May 2 at 3:44
  • one
    $\begingroup$ @Sorfosh Please edit the extra, and very important, information you put in comments into the question. $\endgroup$ May 2 at 13:14

5 Answers five

Reset to default
seventy-three
$\begingroup$

Instead of treating it as a "two turn" game, you can also think about flipping 8 different coins two times each. Let $\mathbf {1}_ {n}$ be the indicator that coin $n$ revealed at least one head in the two flips. Then your score at the end of the game is $\sum_{n=1}^8 \mathbf {1}_n $ . In expectation we get

$$\mathbb{E}\left[ \sum_{n=1}^8 \mathbf {1}_n \right] = \sum_{n = 1}^8 \Pr\left( \text{coin $n$ revealed at least one head} \right) = \sum_{n=1}^8 \frac{3}{4} = 6$$

$\endgroup$
eighteen
$\begingroup$

The shortcut method can be justified formally, but there are some additional details that need to be checked for it to work. To see why, consider an alternate ruleset for the game: imagine that

  1. You begin with flipping all the coins, as before.
  2. However, in the second phase, you're only allowed to select an even number of coins to flip again.

Then the shortcut reasoning still seems to say "after the first phase, we have $4$ heads on average, and we can reflip the other $4$ coins and get $2$ more heads on average". However, in fact, the expected value is not $6$ in the alternate version of the game - it decreases, because sometimes you'll have a coin left over that you're not going to get to flip again.


To justify a shortcut like this formally, and see what needs to happen for it to work, we use the law of total expectation.

The law of total expectation says $\mathbb E[\mathbb E[X \mid Y]] = \mathbb E[X]$ , but the first time I saw that, it made no sense to me, so I'll try to explain it in a bit more detail.

In this case, let $Y$ be the number of heads in the first part of the game, and let $X$ be the number of heads at the end. Then the key is to work out, for every possible value of $Y$ : what is the expected value of $X$ given that value of $Y$ ?

If there are $Y$ coins that land heads in the first phase, then there are $8-Y$ coins that we can flip again. Of those coins, on average, $\frac{8-Y}{2}$ will land heads. Together with the $Y$ coins that were already heads, that's a total of $\frac{8-Y}{2} + Y = \frac{8+Y}{2}$ . This calculation - "when there are $Y$ heads in the first phase, on average there are $\frac{8+Y}{2}$ heads at the end" - is summarized as the equation " $\mathbb E[X \mid Y] = \frac{8+Y}{2}$ ".

The idea behind the law of total expectation is: to figure out the average value of $X$ (whose distribution is a complicated thing we don't understand yet), we can instead figure out the average value of $\frac{8+Y}{2}$ . Here, we have $$\mathbb E\left[\frac{8+Y}2\right] = 4 + \mathbb E[Y/2] = 4 + \mathbb E[Y]/2 = 4 + 4/2 = 6.$$ So the arithmetic is almost as simple as in the shortcut calculation.

However, an important ingredient is computing the formula $\mathbb E[X \mid Y] = \frac{8+Y}{2}$ . This required us to figure out the average value of $X$ for every possible value of $Y$ , not just for the average value of $Y$ . Only once we have the formula $\frac{8+Y}{2}$ can we start looking at the average value of $Y$ .


There is actually another approach that lets us calculate the final distribution, not just its average. Consider what happens from the perspective of a single coin:

  1. It gets flipped in the first phase.
  2. If it lands tails, it gets flipped again in the second phase.

As a result, the probability of the coin being heads at the end is $\frac34$ , and the probability of it being tails is $\frac14$ . In other words, the distribution of the number of heads at the end is simply $\text{Binomial}(n=8, p = \frac34)$ .

$\endgroup$
fifteen
$\begingroup$

It's easiest to consider the each coin flip by itself, and examine the probability of a single coin landing on heads.

On the initial flip, a coin will either land on tails or heads (probability of either is $\frac{1}{2}$ ). If it lands on tails, we flip again and this time the probability of heads after landing on tails is $P(H|T)=\frac{1}{4}$ . You can simply add up the probabilities because of both events are mutually exclusive. The total chance of a coin landing on heads becomes $\frac{1}{2} + \frac{1}{4} = \frac{3}{4}$ .

To get the expected number of heads, multiply our probability by the number of trials to get, $8\times\frac{3}{4} = 6$ heads. This works because each coin flip is independent from the other.

$\endgroup$
seven
$\begingroup$

The number of heads after the first round is a random variable $$X \sim \operatorname{Binomial}(n = 8, p = \tfrac{1}{2}).$$

Given that we observed $X$ heads after the first round, the number of additional heads $Y$ in the second round is also binomial: $$Y \mid X \sim \operatorname{Binomial}(n = 8-X, p = \tfrac{1}{2}).$$

The total number of heads obtained is $X + Y$ .

The expected value of the total number of heads is $$\begin{align}\operatorname{E}[X+Y] &= \operatorname{E}[X] + \operatorname{E}[Y] \\ &= 8 \cdot \frac{1}{2} + \operatorname{E}[\operatorname{E}[Y \mid X]] \\ &= 4 + \operatorname{E}\left[\frac{8-X}{2}\right] \\ &= 4 + \frac{8-\operatorname{E}[X]}{2} \\ &= 4 + \frac{8-4}{2} \\ &= 6. \end{align}$$ Here we used the law of total expectation (also known as the law of iterated expectation, or the tower property of expectation), as well as the linearity of expectation.

As a further exercise:

  • What is the variance of the total number of heads?
  • What are the expectation and variance as a function of some general $n > 1$ and $p \in (0,1)$ ?
$\endgroup$
two
  • $\begingroup$ Very interesting! I observed that $Y|X$ has the distribution you mention, but did not think to use law of total expectation. Thank you! Expectation should be $n/2+n/4$ so $3n/4$. Variance, I am not sure, covaraince would pop up, and then try to use law of total variance somehow? $\endgroup$
    –  Sorfosh
    May 2 at 3:54
  • $\begingroup$ @Sorfosh No, it is not necessary to consider covariance. The law of total variance applies directly: $$\operatorname{Var}[X+Y] = \operatorname{Var}[\operatorname{E}[X+Y \mid X]] + \operatorname{E}[\operatorname{Var}[X+Y \mid X]].$$ You already know $\operatorname{E}[X+Y \mid X]$. But additionally, $$\operatorname{Var}[X+Y \mid X] = \operatorname{Var}[Y \mid X] = (n-X)p(1-p).$$ Note that the first $X$ drops out because it is constant when $X$ is given. $\endgroup$
    –  heropup
    May 2 at 3:57
-1
$\begingroup$

What are the rules exactly? I assume you flip all coins, observe the outcome, and decide which coins to flip a second time.

You obviously flip the tails coins a second time. If you have k tails then flipping them gives an expected number of k/2 heads. The expected number of tails after one throw is 4. Since the function k/2 is so simple the distribution of the number of tails doesn’t matter, so you expect six heads all in all.

Another rule: After the first flip you choose sum k and then k coins are picked at random and flipped. If you had five of more heads you pick k=0. If you had three or fewer heads you pick k=8. With four heads it doesn’t matter.

Let p8, p7, p6 and p5 be the probability of 8 to 5 heads and p the probability of 4 or fewer heads. Then the expected outcome is 4 + 4 * p8 + 3 * p7 + 2 * p6 + p5.

If you have to choose k before knowing the outcome of the first flip you expect 4 heads.

If you have to choose k beforehand but can choose which coins the flip then calculate the expected number of heads for each choice of k and pick the best one.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .