# Finding the expectation: Draws to get 2 gold coins

Omar has saved 11 precious coins, 7 of which made of gold, in a jar. He draws the coins one by one from the jar, to find the gold coins. If $$X$$ is the number of coins drawn until he has found the second gold coin, what is $$E(X)?$$

I have noticed that we have a negative binomial random variable.

$$E(X) = r(1-p)/p,$$ where $$r = 2, p = 7/11,$$ and $$1-p = 4/11.$$

But it doesn't give me the correct answer which is $$3.$$

• Is Omar drawing coins with or without replacement? – BruceET Jul 3 '19 at 2:43
• It is not indicated. – user252587 Jul 3 '19 at 2:44
• Which would be more efficient? Can we assume Omar is smart enough to make the best choice? – BruceET Jul 3 '19 at 2:46
• Perhaps see Wikipedia for alternative formulations of negative binomial dist'n. – BruceET Jul 3 '19 at 5:46

Let's see if we can get this onto the right track:

First, a negative binomial distribution requires independent trials, and so sampling would have to be with replacement.

There are two (principal) versions of the negative binomial distribution. One of them counts the number of failures (non-gold) before the $$r$$th success (gold coin). The other counts the number of the trial on which the $$r$$th success occurs. Logically, you want the second. But you have the expectation formula for the first. The formula for the expectation in the second version is $$E(X) = r/p = 2/(7/11) = 22/7 \approx 3.1429 \ne 3.$$

Second, sampling without replacement is a more efficient way to get 2 gold coins, because any non-gold coins that happen to be drawn are kept out of the jar for subsequent draws. Intuitively then, the number of draws to get 2 gold coins would be a little less---perhaps 3.

When sampling from the jar without replacement, Omar will require between 2 and 6 draws to get two gold coins. So you need to find the probabilities for $$P(X = x),$$ for $$x = 2,3,\dots,6.$$ Then you will find that $$E(X) = \sum_{x=2}^6 xP(X=x) = 3,$$ which is said to be the correct answer.

I will let you find the required probabilities and compute $$E(X).$$

Here is a simulation in R of a million searches (without replacement) for 2 gold coins. In the simulation, 1 stands for a gold coin and 0 stands for a non-gold coin. In R, the samplefunction samples without replacement, by default. With a million iterations, one can expect about two or three decimal places of accuracy from the simulation.

set.seed(2019)
jar = c(1,1,1,1,1,1,1,0,0,0,0)
x = replicate( 10^6, min(which(cumsum(sample(jar,6))==2)) )
mean(x)
 3.002394
2*sd(x)/sqrt(10^6)
 0.00200211     # aprx 95% margin of sim error

round(table(x)/10^6, 3)
x
2     3     4     5     6
0.381 0.339 0.191 0.073 0.015


Hint: $$P(X=3) = P(\text{GNG})+P(\text{NGG})$$ $$= \frac{7}{11}\frac{4}{10}\frac 69 + \frac{4}{11}\frac{7}{10}\frac 69$$ $$= 2\cdot\frac{168}{990}$$ $$\approx 0.3394.$$

Note: A proper simulation in case of sampling with replacement is a little more complicated. In principle, there is no upper bound on the number of draws Omar will have to make.

A risky (improper) simulation is shown below. For the seed shown, I got through a million iterations without once exceeding 20 draws with replacement in order to get 2 gold coins. The program would have crashed if more than 20 draws were ever required. When the program runs, the result is slightly biased on the low side, but approximately correct.

set.seed(702)
jar = c(1,1,1,1,1,1,1,0,0,0,0)
x = replicate(10^6, min(which(cumsum(sample(jar,20, rep=T))==2)))
mean(x)
 3.141441
max(x)
 17    # 20 was barely enough!