# A bet with your friend

James, your friend, has invited you to bet with him.

He has a fair die, with $$3$$ faces showing $$0$$ and $$3$$ faces showing $$1$$. You pay him $$\\\70$$. He throws the die $$15$$ times, and records the sum of the numbers of all throws, and he will give you the recorded number squared dollars. What is the expected gain or loss?

Bonus: At least how many die throw are needed to have an expected gain?

Problem by myself. You have to find an identity to do this question, so this should not be a textbook style problem.

• Suggestion: change the wording of the bonus question because it gives a huge hint on the identity you are asking for :-). Commented Aug 25, 2020 at 13:00
• For the bonus question, I think you mean dice and not coins? There aren't any coins involved in this puzzle. Commented Aug 25, 2020 at 14:11
• @NuclearWang Thanks! Commented Aug 25, 2020 at 14:12

Suppose we have $$n$$ dice. Then

you get $$k^2$$ with probability $${n\choose k}/2^n$$ and your expectation (ignoring the $$\\\70$$ fee for playing) is $$2^{-n}\sum k^2{n\choose k}$$. We have $$k{n\choose k}=n{n-1\choose k-1}$$ so this equals $$2^{-n}n\sum k{n-1\choose k-1}$$. Writing $$k=(k-1)+1$$ and using the same identity with $$n-1,k-1$$ in place of $$n,k$$ we see that this equals $$2^{-n}n(n-1)\sum {n-2\choose k-2}+2^{-n}n\sum {n-1\choose k-1}=\frac14n(n-1)+\frac12n=\frac14n(n+1)$$.

When $$n=15$$

your expected winnings are \$60 per game, not enough to compensate for the \$70 you pay to play. For that, you need $$n(n+1)\geq280$$ which first happens at $$n=17$$.

Just for fun, here's a smartass combinatorial way to prove the identity I used above:

we need $$\sum k^2{n\choose k}=2^{n-2}n(n+1)$$. The first term is the number of ways to choose some number (say $$k$$) of balls from a set of $$n$$, and then choose one of the $$k$$ twice. Instead of doing that, suppose we pick one ball (from the full set of $$n$$) twice, and then choose any subset of the others to fill out our set of $$k$$. There are $$n\cdot2^{n-1}$$ ways to do that if we pick the same ball twice. There are $$2{n\choose 2}\cdot2^{n-2}$$ ways to do it if we pick different balls at the start. Adding these gives the required result.

Perhaps there's a smarter-ass way to do it a bit more briefly.

• Correct! Gotta sleep! Commented Aug 25, 2020 at 14:11

As @Gareth McCaughan was asking for a more smarty pants solution:

What we are asked to compute is the 2nd raw moment of the binomial distribution. This can be written as the variance plus the mean squared which are all well known: $$\sigma^2 + \mu^2 = np(1-p) + (np)^2 = 60$$ with the given parameters. Expected loss is $$\\\10$$

Values at $$16,17$$ are $$68,76.5$$. So to expect a win we need $$17$$ coins.

This solution is wrong, but I leave it here as I think it is an excellent example on how to confuse $$\rm{E}[x^2]$$ and $$\rm{E}[x]^2$$.

The probability of getting $$0$$ (or $$1$$) is $$1/2$$, hence the process you described follows a binomial distribution with parameter $$1/2$$. The expected value of the sum is hence $$15*\frac12=7.5$$, hence your friend will give you $$56.25$$ dollars, resulting in a loss of $$13.75$$ dollars.

The minimum number $$n$$ of die rolls to gain money is given by the equation $$(np)^2>70$$ which gives $$n>\sqrt{70}p^{-1} = 16.73$$ (we discard the negative solution). Then the final answer is $$n=17$$ This die game is equivalent to count the number of heads when flipping a fair coin.

• It looks like you're mixing up (expectation of sum)^2 and expectation of (sum^2). Those are not the same. Commented Aug 25, 2020 at 13:00
• @GarethMcCaughan They are different thing indeed. But I run some simulations and the expected gain that I obtain with 15 rolls is around 56$and not 60$ as you wrote in your answer. Commented Aug 25, 2020 at 13:47
• I also ran some simulations and got 60 and not 56 as you wrote in your answer :-). So it seems like at least one of us is misunderstanding something... Commented Aug 25, 2020 at 13:50
• I did the calculations in Excel and I find 60. Commented Aug 25, 2020 at 13:51
• @GarethMcCaughan: ok I describe my code (as I understand the game proposed by the OP): I simulate 10000 times 15 realizations of uniform random numbers in [0,1]: I count for each time how many random numbers are larger than 0.5: s(k)=#(u>=0.5), u~Uniform(0,1). I take then the mean if this vector and square this mean. But I now realize that it is wrong: I have to square all the elements of s and THEN take the mean. In this way I obtain ~60. As you wrote, I mixed up E[s^2] with (E[s])^2. My fault! Commented Aug 25, 2020 at 14:04

Seems like the answers here are overly complicated.

Assuming: 50% of time the die returns 1, 50% it returns 0. What is the average return on 1 roll? 0.5

What is the average return on 15 rolls? 0.5 times 15 = 7.5 7.5 squared = 56.25

• This is the same mistake Eddymage made above. You're computing $E[x]^2$ instead of $E[x^2]$ Commented Aug 25, 2020 at 22:21
• And it seems you are reading the problem statement wrong. "records the sum of the numbers of all throws, and he will give you the recorded number squared dollars" This shows clearly that the "squaring" happens AFTER the "summing". Commented Aug 25, 2020 at 22:23
• Ah, I think I see what's going on. So, I would say A is the right interpretation, but the sum here is not the same as the sum in the expectation value. The sum in the expectation value is taken over all possible scenarios so we are "squaring then summing" Commented Aug 25, 2020 at 22:54
• @simonalexander2005 From what I understand the error in logic seems to come from conflating the sum of the die values with the sum in the expectation value but they are not the same. Commented Aug 26, 2020 at 9:34
• Right. There are two different summings going on here. To compute the expectation, you consider all possible ways the dice could come up. Then (1) for each one, you sum up the numbers; (2) you then square the result; (3) you then sum up all those results, weighted by their probabilities. (Or, since here the probabilities are all equal, you sum them and divide by the number.) The squaring happens after sum-1 but before sum-2. Commented Aug 27, 2020 at 10:27