# Random Selection Algorithms

There is a bag with mostly blue and some red marbles. If I decide in advance to randomly pick, record the color of, and replace marbles one at a time until I pick one red marble, what is the best estimate I can make about the color ratio in the bag, given that it ends up taking 10 picks to find the first red marble?

If I had decided to pick 10 marbles, and the 10th marble had happened to be the only red marble picked, then the best estimate given the data would have been that the bag is 10% red and 90% blue. Is the outcome different (due to some sort of selection bias or something) in the above example, where instead of picking a set number of marbles, I decide instead to pick until I get my first red result, and it happens to be on the 10th pick? If so, how can the answer be generalized to solve for the best estimate of the color ratio when the red marble is found on the Nth pick?

• There is a difference in the sampling distribution when you sample with replacement a fixed number of times compared to sampling until the first red marble occurs. In the first case the sample size is 10. In the second case the sample size is random. This doesn't change just because that random sample size turns out to be 10. But I wouldn't call this a different outcome. – Michael Chernick Oct 22 '17 at 4:55
• en.wikipedia.org/wiki/Geometric_distribution – Kodiologist Oct 22 '17 at 6:06
• More specifically en.wikipedia.org/wiki/… notes that the MLE is the moment based estimate $1/($number of picks$)$ (it should be stressed this is sampling with replacement!). I don't know whether MLE is the "best" for your purposes – P.Windridge Oct 22 '17 at 10:04

As @Kodiologist notes the number of picks needed to find the first red is geometric and the success probability for each independent pick (with replacement) is $p =$reds/(total marbles).
Thus, the probability for observing the first red on pick $k$ is $p(1-p)^{k-1}$. The log likelihood for of a single observation is $$\ln p + (k-1)\ln(1-p),$$ which is concave for $k>1$ (and trivially maximised at $p=1$ for $k=1$). Taking the first derivative and equating it to $0$ gives the maximum likelihood estimate of $\hat p = 1/k$.
Note that deciding to pick a fixed number $n$ of balls and assuming the only the last is red conditions your outcome (sequence of picks) distribution to agree with geometric conditioned to be $n$.