I am designing a drawing game for a kid's class. A kid could draw a ball out of a box numbered 1, each ball has a number 1, 2, or 3 printed on it. After the kid gets a number, he or she then draws from another box N times (N is the number the kid obtained from the first box) to get N numbers. In the second drawing, each number drawn will be put back to the box for the next draw. And the sum of the numbers drawn from the second box is the number of candies the kid could have. I am trying to find what is the average number of candies each kid could have.
There is a fair chance to have 1,2, or 3 in the first box. The numbers available in the second box is 1,2,3,4,5 in the second box with chance $p_1, p_2, p_3, p_4, p_5$.
My gut feeling tells that the average number of candies should be given as
$$\overline{C} = \frac{1+2+3}{3}\times \sum_{n=1}^5 np_n = 2\sum_{n=1}^5 np_n$$
I did a simulation and it gives me something very close to the formula. However, I want to prove it in a rigorous way and thus I simplify the problem to the following. Let's assume the kid always gets a 2 in the first box and there are 2 numbers (1 and 2) in box 2 with a chance $p_1$ and $p_2$ to be drawn. The kid could get 1-1 (2 candies) or 1-2 (3 candies) or 2-1 (3 candies) or 2-2 (4 candies) from box 2 so the average number of candies in the case should be
$$ \overline{C} = 2p_1^2 + 3p_1p_2 + 3p_2p_1 + 4p_2^2 = 2(1+p_2) = 2(p_1+2p_2) $$ It seems to match the conclusion I have before. But how to generalize it to the case of the initial problem?
The first part of your analysis is an application of the law of total expectation
In your simplified example, the two expressions $2p_1^2 + 3p_1p_2 + 3p_2p_1 + 4p_2^2$ and $2(1p_1+ 2p_2)$ are equal if you use $p_1+p_2=1$, as they are both equal to any of $2p_1+4p_2=2+2p_2 = 4-2p_1 = 3+p_2-p_1$. You can see this with
$$2p_1^2 + 3p_1p_2 + 3p_2p_1 + 4p_2^2 \\= 2p_1^2 + 2p_1p_2 +4p_1p_2 +4p_2^2 \\= 2p_1(p_1+p_2) +4(p_1+p_2)p_2 \\= 2p_1+4p_2\\ = 2(1p_1+ 2p_2)$$