What is the expected number of apples that will be left in the basket?

2,688

So we're looking for an average over all possible orders to pull the apples out in. (We'll include the ones after the last green one goes.) Here's one way to choose the order; I hope it's clear that it generates all orders with equal probability.

First, decide what order to take the green ones in.

Then, successively for each red apple, decide its position relative to the apples already placed.

Note that each red apple is then equally likely to lie in each of the five regions "before first green apple", "between first and second green apples", ..., "after fourth green apple".

This means that for a given red apple Pr(this apple is still there after the last green one is taken) = 1/5.

So the expected number of red apples left after the last green one is taken is $50\times\frac{1}{5}$ = 10.

Share:
2,688
Newskooler
Author by

Newskooler

I love to ski and snowmobile. When off the mountain, I enjoy spending time surfing and bjj. All questions, answers, comments and code are from me personally, and in no way represent the opinions of my employer.

Updated on September 07, 2020

Comments

  • Newskooler
    Newskooler about 3 years

    Hi stumbled upon this interview question: There are 4 green and 50 red apples in a basket. They are removed one-by-one, without replacement, until all 4 green ones are extracted. What is the expected number of apples that will be left in the basket?

    At first I thought it was 0, because there is always a chance for a green apple to be left in the basket, however since they are asking for the expected number of apples left, it actually makes sense that the number is positive. I found out that the answers is most likely 10, from various websites, however there is no solution anywhere. I have been trying to approach it with probabilities and with combination, however no luck so far. Some hints or a solution will be much appreciated.

    • Sarvesh Ravichandran Iyer
      Sarvesh Ravichandran Iyer about 7 years
      Do you have the individual probability that $m$ red apples are picked before the $4$ green apples? Then you can directly use the definition of the expectation value.
    • Newskooler
      Newskooler about 7 years
      I see, unfortunately this is all the information I have.
    • Sarvesh Ravichandran Iyer
      Sarvesh Ravichandran Iyer about 7 years
      Ok, so do you know how to calculate the above quantity, or should I include that in my answer?
    • Newskooler
      Newskooler about 7 years
      Please include it in the answer. Thanks!
    • Newskooler
      Newskooler about 7 years
      @GarethMcCaughan Indeed. Thanks, I was trying to find such a question.
  • Sarvesh Ravichandran Iyer
    Sarvesh Ravichandran Iyer about 7 years
    That's a very neat answer.
  • Gareth McCaughan
    Gareth McCaughan about 7 years
    Thanks. (I worry that it may be difficult to grasp for someone who hasn't seen this kind of reasoning before, but I think the effort is worth it.)
  • Sarvesh Ravichandran Iyer
    Sarvesh Ravichandran Iyer about 7 years
    It's worth it all right. I prefer an introduction via this argument rather than brute force.
  • Newskooler
    Newskooler about 7 years
    I placed this formula in excel and verified it that it works with the 4 green 60 red apples as well. After that I drew what you said (easier for me to grasp) and I think it all makes sense. Interesting approach. Thank you! P.S. I put in my reasoning too as it may help someone else.