St · Statistics & Probability

What Is the Expected Number of Apples Left in the Basket?

Published By the 9to5Science editorial team

At a glance

  1. 1. Specify the setup

    Identify the number of apples and exactly how apples are selected, removed, or returned.

  2. 2. Track survival

    For each apple, determine the probability that it remains in the basket.

  3. 3. Add probabilities

    Sum the survival probabilities to get the expected number left.

Advertisement

The expected number of apples left cannot be determined from the basket alone. You need the starting number of apples and the rules for choosing, eating, removing, or replacing them. Different rules can give different answers, even when the basket starts with the same number.

A general method works for many versions of the problem: calculate the probability that each apple remains, then add those probabilities.

Use indicator variables

Suppose the basket starts with NN apples. For apple ii, define an indicator variable IiI_i that equals 1 if that apple is still in the basket at the end and 0 otherwise. The total number left is

L=I1+I2+⋯+IN.L=I_1+I_2+\cdots+I_N.

By linearity of expectation,

E[L]=∑i=1NE[Ii]=∑i=1NPr⁡(apple i remains).\mathbb{E}[L]=\sum_{i=1}^{N}\mathbb{E}[I_i]=\sum_{i=1}^{N}\Pr(\text{apple }i\text{ remains}).

This works whether the apples’ fates are independent or not. You do not need to find the full probability distribution of the total; you only need each apple’s chance of remaining.

If a fixed number of apples is removed

If there are NN apples and exactly kk are removed, then the number left is always N−kN-k. Since it is not random, its expected value is also

E[L]=N−k.\mathbb{E}[L]=N-k.

For example, if a basket has 12 apples and 5 are selected and removed, 7 are left every time. The expected number left is 7, regardless of whether the 5 apples were chosen uniformly at random.

Random selection matters when you ask about a particular kind of apple, or when the number removed is itself random.

Worked example: expected number of red apples left

Suppose a basket has 12 apples, 5 of them red. Four apples are chosen uniformly at random without replacement and removed. The total number left is always 12−4=812-4=8. To find the expected number of red apples left, consider each of the 5 red apples separately.

A particular red apple has probability 4/124/12 of being selected for removal, so its probability of remaining is 1−4/12=8/121-4/12=8/12. Adding that survival probability for all 5 red apples gives

E[red apples left]=5(812)=103.\mathbb{E}[\text{red apples left}] =5\left(\frac{8}{12}\right) =\frac{10}{3}.

The expected count is 10/310/3, or about 3.33. That does not mean a basket can contain a fraction of an apple. It means that over many repetitions of the same random procedure, the average number of red apples left approaches 3.33.

More generally, if RR of NN apples are a particular type and exactly kk apples are removed uniformly without replacement, then each apple has probability (N−k)/N(N-k)/N of remaining. Thus the expected number of that type left is

RN−kN.R\frac{N-k}{N}.

If each apple has a chance of being removed

Suppose each of NN apples is independently removed with probability qq. Each apple then remains with probability 1−q1-q, so

E[L]=N(1−q).\mathbb{E}[L]=N(1-q).

For instance, if there are 10 apples and each has a 20% chance of being removed, the expected number left is 10(0.8)=810(0.8)=8. The actual count can vary from one repetition to another; 8 is the average in the long run.

Independence is not needed for this expectation formula if each apple still has the same probability of remaining. Independence would matter for calculating other quantities, such as the probability that exactly 8 remain.

Common mistakes

  • Assuming a random choice changes the total left. If exactly kk apples are removed, the total remaining is fixed at N−kN-k; randomness affects which apples remain, not how many.
  • Confusing an expected count with a guaranteed count. An expectation can be non-integer and need not be a count that occurs in any one trial.
  • Leaving out the removal rules. “Apples are chosen at random” is not enough by itself. You need to know how many are chosen, whether they are returned, and whether choices repeat.
  • Treating apples as equally likely to remain without justification. That is appropriate for uniform selection, but not if some apples are more likely to be removed than others.

To get a specific numerical answer for a particular basket puzzle, state the starting number of apples and the complete selection or removal procedure. Then apply the indicator method, or subtract the number removed if that number is fixed.

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.